結果

問題 No.16 累乗の加算
ユーザー skewesskewes
提出日時 2015-12-29 21:43:58
言語 C#(csc)
(csc 3.9.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 982 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 107,392 KB
実行使用メモリ 22,912 KB
最終ジャッジ日時 2024-04-24 09:41:46
合計ジャッジ時間 2,339 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
18,944 KB
testcase_01 AC 29 ms
18,944 KB
testcase_02 AC 31 ms
19,456 KB
testcase_03 AC 35 ms
20,864 KB
testcase_04 AC 38 ms
21,120 KB
testcase_05 AC 36 ms
20,864 KB
testcase_06 AC 44 ms
22,656 KB
testcase_07 AC 36 ms
20,864 KB
testcase_08 AC 35 ms
20,608 KB
testcase_09 AC 34 ms
20,864 KB
testcase_10 AC 42 ms
22,656 KB
testcase_11 AC 30 ms
19,584 KB
testcase_12 AC 44 ms
22,912 KB
testcase_13 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

namespace yukicoder
{
    class _016
    {
        static int[] p;
        static void Main()
        {
            int[] xn = Array.ConvertAll(Console.ReadLine().Split(' ')
                , x => int.Parse(x));
            int[] an = Array.ConvertAll(Console.ReadLine().Split(' ')
                , x => int.Parse(x));
            int m = an.Max();
            p = new int[m + 1];
            int l = c(xn[0], m);
            int ans = 0;
            foreach(int a in an)
            {
                ans += p[l == 1 ? a : a % l];
            }
            Console.WriteLine(ans % 1000003);
        }
        static int c(int x, int m)
        {
            int l = 1;
            p[0] = 1;
            for (int i = 1; i < m + 1; i++)
            {
                p[i] = p[i -1] * x % 1000003;

                if (p[i] == 1)
                {
                    return i;
                }
            }
            return l;
        }
    }
}
0