結果

問題 No.888 約数の総和
ユーザー tomomo2b2tomomo2b2
提出日時 2019-10-11 18:06:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 3,177 ms
コンパイル使用メモリ 102,852 KB
実行使用メモリ 23,320 KB
最終ジャッジ日時 2023-08-16 11:36:21
合計ジャッジ時間 6,400 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
21,012 KB
testcase_01 AC 60 ms
20,916 KB
testcase_02 AC 60 ms
21,348 KB
testcase_03 AC 58 ms
20,812 KB
testcase_04 AC 59 ms
22,844 KB
testcase_05 AC 58 ms
18,948 KB
testcase_06 AC 58 ms
20,916 KB
testcase_07 AC 58 ms
21,276 KB
testcase_08 AC 59 ms
23,052 KB
testcase_09 AC 58 ms
20,928 KB
testcase_10 AC 58 ms
23,320 KB
testcase_11 AC 60 ms
20,828 KB
testcase_12 AC 59 ms
19,036 KB
testcase_13 AC 60 ms
23,004 KB
testcase_14 AC 58 ms
23,032 KB
testcase_15 AC 57 ms
20,844 KB
testcase_16 AC 58 ms
21,052 KB
testcase_17 AC 58 ms
21,192 KB
testcase_18 AC 58 ms
21,108 KB
testcase_19 AC 57 ms
21,192 KB
testcase_20 AC 58 ms
21,264 KB
testcase_21 AC 59 ms
21,288 KB
testcase_22 AC 58 ms
23,316 KB
testcase_23 AC 58 ms
19,212 KB
testcase_24 AC 60 ms
21,032 KB
testcase_25 AC 59 ms
21,128 KB
testcase_26 AC 60 ms
22,920 KB
testcase_27 AC 60 ms
21,032 KB
testcase_28 AC 59 ms
20,944 KB
testcase_29 AC 58 ms
20,852 KB
testcase_30 AC 58 ms
20,860 KB
testcase_31 AC 58 ms
21,300 KB
testcase_32 AC 59 ms
19,124 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Collections.Generic;
using System.IO;

class MyClass
{
    public static void Solve()
    {
        var N = long.Parse(Console.ReadLine());
        var exp = new Dictionary<long, long>();
        long sum = 1;
        if (N % 2 == 0)
        {
            exp.Add(2, 0);
            while (N % 2 == 0)
            {
                N /= 2;
                exp[2]++;
            }
        }
        for (long p = 3; p * p <= N; p += 2)
        {
            if (N % p == 0)
            {
                exp.Add(p, 0);
                while (N % p == 0)
                {
                    N /= p;
                    exp[p]++;
                }
            }
        }
        if (N != 1)
        {
            exp.Add(N, 1);
        }
        foreach (var p in exp.Keys)
        {
            long factor = 0;
            for (int i = 0; i <= exp[p]; i++)
            {
                factor += (long)Math.Pow(p, i);
            }
            sum *= factor;
        }
        Console.WriteLine(sum);
    }

    public static void Main()
    {
        var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
0