結果

問題 No.2260 Adic Sum
ユーザー nmynmy
提出日時 2023-04-08 12:43:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 867 ms / 2,000 ms
コード長 594 bytes
コンパイル時間 2,486 ms
コンパイル使用メモリ 206,352 KB
実行使用メモリ 88,448 KB
最終ジャッジ日時 2024-04-16 00:00:28
合計ジャッジ時間 8,352 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 3 ms
5,376 KB
testcase_10 AC 3 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 22 ms
6,016 KB
testcase_15 AC 32 ms
7,168 KB
testcase_16 AC 19 ms
5,640 KB
testcase_17 AC 34 ms
7,424 KB
testcase_18 AC 504 ms
52,736 KB
testcase_19 AC 545 ms
56,064 KB
testcase_20 AC 383 ms
37,760 KB
testcase_21 AC 370 ms
38,144 KB
testcase_22 AC 312 ms
32,640 KB
testcase_23 AC 198 ms
20,992 KB
testcase_24 AC 492 ms
51,456 KB
testcase_25 AC 56 ms
9,728 KB
testcase_26 AC 55 ms
9,600 KB
testcase_27 AC 60 ms
9,984 KB
testcase_28 AC 54 ms
9,728 KB
testcase_29 AC 56 ms
9,856 KB
testcase_30 AC 55 ms
8,064 KB
testcase_31 AC 140 ms
12,160 KB
testcase_32 AC 138 ms
12,288 KB
testcase_33 AC 57 ms
10,752 KB
testcase_34 AC 170 ms
30,976 KB
testcase_35 AC 867 ms
88,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, p;
  cin >> n >> p;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<ll> f = {1};
  while(f.back()*p <= 1e9){
    f.push_back(f.back()*p);
  }
  int m = f.size();
  vector<map<ll,ll>> mp(30);
  for(int i = 0; i < m; i++){
    for(int j = 0; j < n; j++){
      mp[i][a[j]%f[i]]++;
    }
  }
  ll ans = 0;
  map<ll,ll> mq;
  for(int i = 1; i < m; i++){
    for(auto [k, v]: mp[i]){
      ans += v*(v-1)/2;
    }
  }
  cout << ans << endl;
}
0