結果

問題 No.2260 Adic Sum
ユーザー hongrockhongrock
提出日時 2023-04-09 15:41:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 373 ms / 2,000 ms
コード長 1,039 bytes
コンパイル時間 2,314 ms
コンパイル使用メモリ 199,756 KB
実行使用メモリ 8,940 KB
最終ジャッジ日時 2024-04-16 00:03:21
合計ジャッジ時間 5,754 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 2 ms
5,376 KB
testcase_12 AC 3 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 14 ms
5,376 KB
testcase_15 AC 21 ms
5,888 KB
testcase_16 AC 12 ms
5,376 KB
testcase_17 AC 22 ms
5,912 KB
testcase_18 AC 215 ms
8,908 KB
testcase_19 AC 248 ms
8,812 KB
testcase_20 AC 147 ms
8,924 KB
testcase_21 AC 163 ms
8,924 KB
testcase_22 AC 138 ms
8,792 KB
testcase_23 AC 83 ms
8,352 KB
testcase_24 AC 200 ms
8,940 KB
testcase_25 AC 34 ms
8,332 KB
testcase_26 AC 35 ms
8,196 KB
testcase_27 AC 37 ms
8,348 KB
testcase_28 AC 35 ms
8,208 KB
testcase_29 AC 36 ms
8,336 KB
testcase_30 AC 30 ms
6,056 KB
testcase_31 AC 86 ms
6,248 KB
testcase_32 AC 85 ms
6,376 KB
testcase_33 AC 29 ms
8,360 KB
testcase_34 AC 75 ms
8,360 KB
testcase_35 AC 373 ms
8,812 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define rep(i, a, n) for(int i=(a); i<(n); ++i)
#define per(i, a, n) for(int i=(a); i>(n); --i)
#define pb emplace_back
#define mp make_pair
#define clr(a, b) memset(a, b, sizeof(a))
#define all(x) (x).begin(),(x).end()
#define lowbit(x) (x & -x)
#define fi first
#define se second
#define lson o<<1
#define rson o<<1|1
#define gmid l[o]+r[o]>>1
 
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using ui = unsigned int;
 
constexpr int mod = 998244353;
constexpr int inf = 0x3f3f3f3f;
constexpr double EPS = 1e-8;
const double PI = acos(-1.0);

constexpr int N = 2e5 + 10;

void _main(){
  int lim = 1e9;
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  rep(i, 0, n)  cin >> a[i];
  ll ans = 0;
  for(ll i=p; i<=lim; i*=p){
    unordered_map<int, int> cnt;
    for(int v : a){
      ans += cnt[v % i]++;
    }
  }
  cout << ans << '\n';
}

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  _main();
  return 0;
}
0