結果

問題 No.2260 Adic Sum
ユーザー nononnonon
提出日時 2023-07-13 18:11:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,801 ms / 2,000 ms
コード長 1,231 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 209,204 KB
実行使用メモリ 87,768 KB
最終ジャッジ日時 2023-10-13 07:11:06
合計ジャッジ時間 14,235 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,352 KB
testcase_08 AC 4 ms
4,348 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 3 ms
4,352 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 3 ms
4,352 KB
testcase_13 AC 4 ms
4,348 KB
testcase_14 AC 31 ms
5,776 KB
testcase_15 AC 45 ms
7,064 KB
testcase_16 AC 26 ms
5,420 KB
testcase_17 AC 50 ms
7,148 KB
testcase_18 AC 1,115 ms
52,096 KB
testcase_19 AC 1,166 ms
55,300 KB
testcase_20 AC 689 ms
37,048 KB
testcase_21 AC 712 ms
37,528 KB
testcase_22 AC 583 ms
31,988 KB
testcase_23 AC 292 ms
20,424 KB
testcase_24 AC 1,081 ms
50,840 KB
testcase_25 AC 82 ms
9,132 KB
testcase_26 AC 80 ms
9,012 KB
testcase_27 AC 83 ms
9,320 KB
testcase_28 AC 84 ms
9,064 KB
testcase_29 AC 83 ms
9,240 KB
testcase_30 AC 88 ms
7,304 KB
testcase_31 AC 204 ms
11,492 KB
testcase_32 AC 203 ms
11,624 KB
testcase_33 AC 82 ms
9,928 KB
testcase_34 AC 247 ms
30,336 KB
testcase_35 AC 1,801 ms
87,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using db = long double;
using ch = char;
using bl = bool;
using st = string;
using pll = pair<ll,ll>;
using psl = pair<st,ll>;
using vst = vector<st>;
using vch = vector<ch>;
using vvch = vector<vch>;
using vbl = vector<bl>;
using vvbl = vector<vbl>;
using vdb = vector<db>;
using vpll = vector<pll>;
using vpsl = vector<psl>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vvvvvll = vector<vvvvll>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i,a,b) for(int i=(ll)(a);i<=(ll)(b);i++)

int main() {
    ll N,P;
    cin>>N>>P;
    ll p=P;
    vll list;
    while(p<1e9){
        list.push_back(p);
        p*=P;
    }
    ll n=list.size();
    vector<map<ll,ll>> A(n);
    rep(i,N){
        ll a;
        cin>>a;
        rep(j,n){
            A[j][a%list[j]]++;
        }
    }
    ll ans=0;
    rep(j,n){
        for(auto x:A[j]){
            ll y=x.second;
            ans+=y*(y-1)/2;
        }
    }
    cout << ans << endl;
    return 0;
}
0