結果

問題 No.888 約数の総和
ユーザー iwkjosec
提出日時 2019-09-25 22:28:47
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 611 bytes
コンパイル時間 2,078 ms
コンパイル使用メモリ 109,368 KB
実行使用メモリ 27,028 KB
最終ジャッジ日時 2024-09-22 18:12:44
合計ジャッジ時間 3,965 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 RE * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        WriteLine(yakusuu(N).Sum());
    }

    public static int[] yakusuu(int n)//O(sqrt N)
    {
        if (n < 1) return new int[0];//Assert
        var r = new List<int>();
        for (int i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                r.Add(i);
                if (i * i != n) r.Add(n / i);
            }
        }
        return r.ToArray();
    }
}
0