結果

問題 No.2709 1975 Powers
ユーザー akinyanakinyan
提出日時 2024-03-31 13:53:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 746 ms / 2,000 ms
コード長 1,526 bytes
コンパイル時間 3,378 ms
コンパイル使用メモリ 261,056 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 13:53:39
合計ジャッジ時間 11,658 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 7 ms
6,676 KB
testcase_03 AC 385 ms
6,676 KB
testcase_04 AC 595 ms
6,676 KB
testcase_05 AC 403 ms
6,676 KB
testcase_06 AC 126 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 114 ms
6,676 KB
testcase_09 AC 402 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 12 ms
6,676 KB
testcase_12 AC 32 ms
6,676 KB
testcase_13 AC 448 ms
6,676 KB
testcase_14 AC 59 ms
6,676 KB
testcase_15 AC 67 ms
6,676 KB
testcase_16 AC 343 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 40 ms
6,676 KB
testcase_19 AC 611 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 113 ms
6,676 KB
testcase_22 AC 729 ms
6,676 KB
testcase_23 AC 729 ms
6,676 KB
testcase_24 AC 726 ms
6,676 KB
testcase_25 AC 746 ms
6,676 KB
testcase_26 AC 730 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef akinyan
#define akinyan
#include <bits/stdc++.h>
using namespace std;
using ch = char;
using ll = long long;
using ld = long double;
using db = double;
using st = string;
using vdb = vector<db>;
using vvdb = vector<vdb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<ld>;
using vvd = vector<vd>;
using vs = vector<st>;
using vvs = vector<vs>;
using vc = vector<ch>;
using vvc = vector<vc>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
const ll mod = 998244353;
const ll MOD = 1000000007;
const ll INF = 1000000000000000000LL;
using pall = pair<ll,ll>;
using vp = vector<pall>;
#endif

ll modpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

int main(){
    ll N,P,Q;
    cin>>N>>P>>Q;
    vl A(N);
    for(int i=0; i<N; i++){
        cin>>A[i];
    }
    ranges::sort(A);
    vvl X(N,vl(4));
    for(int i=0; i<N; i++){
        X[i][0] = modpow(10,A[i],P);
        X[i][1] = modpow(9,A[i],P);
        X[i][2] = modpow(7,A[i],P);
        X[i][3] = modpow(5,A[i],P);
    }
    ll ans = 0;
    for(int a=0; a<N; a++){
        for(int b=a+1; b<N; b++){
            for(int c=b+1; c<N; c++){
                for(int d=c+1; d<N; d++){
                    if((X[a][0] + X[b][1] + X[c][2] + X[d][3]) % P == Q){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
0