結果

問題 No.2260 Adic Sum
ユーザー hourenhouren
提出日時 2023-04-07 21:31:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 601 ms / 2,000 ms
コード長 842 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 175,912 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-15 23:44:06
合計ジャッジ時間 6,455 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 3 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 3 ms
6,940 KB
testcase_11 AC 2 ms
6,948 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 3 ms
6,940 KB
testcase_14 AC 18 ms
6,944 KB
testcase_15 AC 25 ms
7,296 KB
testcase_16 AC 16 ms
6,940 KB
testcase_17 AC 37 ms
7,552 KB
testcase_18 AC 351 ms
9,728 KB
testcase_19 AC 401 ms
10,368 KB
testcase_20 AC 259 ms
9,984 KB
testcase_21 AC 266 ms
10,112 KB
testcase_22 AC 218 ms
9,984 KB
testcase_23 AC 101 ms
10,240 KB
testcase_24 AC 346 ms
10,112 KB
testcase_25 AC 46 ms
9,728 KB
testcase_26 AC 44 ms
9,600 KB
testcase_27 AC 46 ms
9,984 KB
testcase_28 AC 44 ms
9,728 KB
testcase_29 AC 47 ms
9,856 KB
testcase_30 AC 52 ms
7,552 KB
testcase_31 AC 122 ms
8,064 KB
testcase_32 AC 135 ms
8,064 KB
testcase_33 AC 50 ms
10,368 KB
testcase_34 AC 128 ms
10,240 KB
testcase_35 AC 601 ms
10,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,p,q,ans = 0;
    cin >> n >> p;
    q = p;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    while(q<=1e9){
        map<int,ll> mp;
        rep(i,n){
            ans += (mp[a[i]%q]++);
        }
        q *= p;
    }
    cout << ans << '\n';
    return 0;
}
0