結果

問題 No.2260 Adic Sum
ユーザー 👑 kakel-sankakel-san
提出日時 2023-06-29 21:56:40
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 455 ms / 2,000 ms
コード長 1,026 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 67,896 KB
実行使用メモリ 50,408 KB
最終ジャッジ日時 2023-09-20 16:56:34
合計ジャッジ時間 10,359 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
21,824 KB
testcase_01 AC 63 ms
23,896 KB
testcase_02 AC 64 ms
21,796 KB
testcase_03 AC 63 ms
23,752 KB
testcase_04 AC 63 ms
21,812 KB
testcase_05 AC 64 ms
23,760 KB
testcase_06 AC 64 ms
21,752 KB
testcase_07 AC 63 ms
23,744 KB
testcase_08 AC 71 ms
22,024 KB
testcase_09 AC 70 ms
21,780 KB
testcase_10 AC 71 ms
22,108 KB
testcase_11 AC 71 ms
23,884 KB
testcase_12 AC 71 ms
24,124 KB
testcase_13 AC 72 ms
22,224 KB
testcase_14 AC 93 ms
27,016 KB
testcase_15 AC 100 ms
30,280 KB
testcase_16 AC 88 ms
25,516 KB
testcase_17 AC 107 ms
30,768 KB
testcase_18 AC 304 ms
44,972 KB
testcase_19 AC 320 ms
50,408 KB
testcase_20 AC 244 ms
49,348 KB
testcase_21 AC 250 ms
50,092 KB
testcase_22 AC 224 ms
48,376 KB
testcase_23 AC 197 ms
47,632 KB
testcase_24 AC 319 ms
47,820 KB
testcase_25 AC 121 ms
37,448 KB
testcase_26 AC 121 ms
37,408 KB
testcase_27 AC 123 ms
38,704 KB
testcase_28 AC 121 ms
36,592 KB
testcase_29 AC 122 ms
38,584 KB
testcase_30 AC 134 ms
32,768 KB
testcase_31 AC 382 ms
42,024 KB
testcase_32 AC 380 ms
41,992 KB
testcase_33 AC 129 ms
38,888 KB
testcase_34 AC 172 ms
47,072 KB
testcase_35 AC 455 ms
48,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, p) = (c[0], c[1]);
        var a = NList;
        var max = a.Max();
        var div = (long)p;
        var ans = 0L;
        while (true)
        {
            if (div >= max) break;
            var dic = new Dictionary<long, int>();
            foreach (var ai in a)
            {
                var am = ai % div;
                if (dic.ContainsKey(am))
                {
                    ans += dic[am];
                    ++dic[am];
                }
                else dic[am] = 1;
            }
            div *= p;
        }
        WriteLine(ans);
    }
}
0