結果

問題 No.2260 Adic Sum
ユーザー 👑 KazunKazun
提出日時 2023-04-07 21:30:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 450 ms / 2,000 ms
コード長 412 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,588 KB
実行使用メモリ 179,088 KB
最終ジャッジ日時 2024-04-15 23:43:31
合計ジャッジ時間 6,017 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
54,648 KB
testcase_01 AC 44 ms
54,280 KB
testcase_02 AC 45 ms
55,044 KB
testcase_03 AC 45 ms
55,176 KB
testcase_04 AC 44 ms
55,312 KB
testcase_05 AC 44 ms
54,472 KB
testcase_06 AC 44 ms
54,820 KB
testcase_07 AC 43 ms
53,952 KB
testcase_08 AC 51 ms
62,472 KB
testcase_09 AC 45 ms
55,440 KB
testcase_10 AC 51 ms
61,272 KB
testcase_11 AC 45 ms
55,588 KB
testcase_12 AC 54 ms
64,692 KB
testcase_13 AC 53 ms
64,188 KB
testcase_14 AC 67 ms
78,468 KB
testcase_15 AC 78 ms
86,648 KB
testcase_16 AC 66 ms
77,176 KB
testcase_17 AC 83 ms
89,932 KB
testcase_18 AC 307 ms
147,716 KB
testcase_19 AC 319 ms
164,120 KB
testcase_20 AC 235 ms
147,944 KB
testcase_21 AC 229 ms
143,612 KB
testcase_22 AC 211 ms
144,992 KB
testcase_23 AC 164 ms
114,508 KB
testcase_24 AC 310 ms
162,592 KB
testcase_25 AC 97 ms
102,948 KB
testcase_26 AC 94 ms
98,944 KB
testcase_27 AC 98 ms
104,168 KB
testcase_28 AC 97 ms
103,536 KB
testcase_29 AC 99 ms
103,220 KB
testcase_30 AC 102 ms
90,772 KB
testcase_31 AC 208 ms
90,740 KB
testcase_32 AC 207 ms
90,808 KB
testcase_33 AC 102 ms
92,704 KB
testcase_34 AC 137 ms
109,272 KB
testcase_35 AC 450 ms
179,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    from collections import defaultdict

    N,P=map(int,input().split())
    A=list(map(int,input().split()))

    A_max=max(A)

    Ans=0; v=1; Q=P
    while Q<=A_max:
        E=defaultdict(int)
        for a in A:
            E[a%Q]+=1

        for y in E.values():
            Ans+=y*(y-1)//2
        v+=1; Q*=P
    return Ans

#==================================================
print(solve())
0