結果

問題 No.2260 Adic Sum
ユーザー _yurimoir_yurimoir
提出日時 2023-04-08 07:07:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 822 ms / 2,000 ms
コード長 585 bytes
コンパイル時間 3,627 ms
コンパイル使用メモリ 284,292 KB
実行使用メモリ 10,496 KB
最終ジャッジ日時 2024-04-15 23:59:58
合計ジャッジ時間 10,279 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 3 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 4 ms
5,376 KB
testcase_14 AC 47 ms
6,104 KB
testcase_15 AC 70 ms
7,168 KB
testcase_16 AC 38 ms
5,880 KB
testcase_17 AC 79 ms
7,680 KB
testcase_18 AC 482 ms
9,728 KB
testcase_19 AC 543 ms
10,112 KB
testcase_20 AC 378 ms
10,112 KB
testcase_21 AC 389 ms
9,984 KB
testcase_22 AC 337 ms
9,856 KB
testcase_23 AC 232 ms
10,240 KB
testcase_24 AC 503 ms
10,496 KB
testcase_25 AC 128 ms
9,856 KB
testcase_26 AC 131 ms
9,600 KB
testcase_27 AC 142 ms
9,984 KB
testcase_28 AC 124 ms
9,728 KB
testcase_29 AC 127 ms
9,856 KB
testcase_30 AC 126 ms
10,368 KB
testcase_31 AC 176 ms
10,240 KB
testcase_32 AC 174 ms
10,240 KB
testcase_33 AC 105 ms
10,240 KB
testcase_34 AC 197 ms
10,240 KB
testcase_35 AC 822 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    for(auto& x : a) cin >> x;
    vector<int> tank = {p};
    for(int i = 0; i < 60; i++){
        if(tank.back() > 1e9) break;
        tank.push_back(tank.back() * p);
    }
    int ans = 0;
    for(int v : tank){
        map<int, int> mp;
        for(int i = 0; i < n; i++){
            mp[a[i] % v]++;
        }
        for(auto[key, val] : mp){
            ans += val * (val - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}
0