結果

問題 No.278 連続する整数の和(2)
ユーザー kazukuro27kazukuro27
提出日時 2015-09-05 14:16:45
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 879 bytes
コンパイル時間 4,908 ms
コンパイル使用メモリ 104,392 KB
実行使用メモリ 25,244 KB
最終ジャッジ日時 2023-09-26 08:47:15
合計ジャッジ時間 8,301 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
25,244 KB
testcase_01 AC 55 ms
20,684 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

class Program
{
    static void Main()
    {
        Int64 n = Int64.Parse(Console.ReadLine());
        Int64 temp = n * ( n - 1 )/2;
        Int64 i ;
        Int64 ans;
        var list = new List<Pair>();

        i = 2;
        while(temp != 1)
        {
            Int64 count = 0;

            while (temp % i == 0)
            {
                count++;
                temp /= i;
            }

            if (count > 0)
                list.Add(new Pair(i, count));

            i++;
        }

        ans = 1;

        foreach (Pair p in list)
        {
            ans *= ((Int64)(Math.Pow(p.x, p.n+1)) - 1) / (p.x - 1);
        }

        Console.WriteLine(ans);
    }
}

struct Pair
{
    public Int64 x;
    public Int64 n;

    public Pair(Int64 x, Int64 n)
    {
        this.x = x;
        this.n = n;
    }
}
0