結果

問題 No.888 約数の総和
ユーザー tomomo2b2tomomo2b2
提出日時 2019-10-11 18:06:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 2,548 ms
コンパイル使用メモリ 111,040 KB
実行使用メモリ 26,360 KB
最終ジャッジ日時 2024-11-25 00:01:39
合計ジャッジ時間 4,176 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
24,172 KB
testcase_01 AC 25 ms
24,172 KB
testcase_02 AC 24 ms
24,036 KB
testcase_03 AC 22 ms
25,696 KB
testcase_04 AC 26 ms
24,300 KB
testcase_05 AC 26 ms
24,048 KB
testcase_06 AC 24 ms
24,172 KB
testcase_07 AC 23 ms
24,168 KB
testcase_08 AC 24 ms
26,224 KB
testcase_09 AC 23 ms
24,164 KB
testcase_10 AC 24 ms
26,360 KB
testcase_11 AC 24 ms
24,364 KB
testcase_12 AC 24 ms
26,116 KB
testcase_13 AC 24 ms
26,240 KB
testcase_14 AC 24 ms
26,232 KB
testcase_15 AC 23 ms
24,196 KB
testcase_16 AC 23 ms
24,168 KB
testcase_17 AC 24 ms
24,116 KB
testcase_18 AC 24 ms
26,240 KB
testcase_19 AC 24 ms
24,108 KB
testcase_20 AC 23 ms
24,168 KB
testcase_21 AC 24 ms
24,468 KB
testcase_22 AC 25 ms
26,208 KB
testcase_23 AC 24 ms
23,916 KB
testcase_24 AC 24 ms
25,992 KB
testcase_25 AC 24 ms
26,120 KB
testcase_26 AC 25 ms
24,044 KB
testcase_27 AC 26 ms
26,116 KB
testcase_28 AC 25 ms
23,912 KB
testcase_29 AC 24 ms
24,068 KB
testcase_30 AC 25 ms
26,112 KB
testcase_31 AC 24 ms
24,332 KB
testcase_32 AC 24 ms
26,116 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