結果

問題 No.2709 1975 Powers
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-31 15:20:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 928 bytes
コンパイル時間 2,070 ms
コンパイル使用メモリ 208,180 KB
実行使用メモリ 82,176 KB
最終ジャッジ日時 2024-03-31 15:20:15
合計ジャッジ時間 10,977 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 4 ms
6,676 KB
testcase_02 AC 32 ms
26,496 KB
testcase_03 AC 404 ms
70,016 KB
testcase_04 AC 622 ms
78,976 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 8 ms
10,752 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 8 ms
11,136 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 120 ms
45,696 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 643 ms
82,176 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 716 ms
82,176 KB
testcase_26 AC 675 ms
82,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long repeat2(long long a, long long b,long long mod){
    long long p = a%mod,ret = 1;
    while(b){
        if(b&1) ret = ret*p %mod;
        p = p*p %mod; b >>= 1;
    }
    return ret;
}

int main() {
    int N,P,Q; cin >> N >> P >> Q;
    vector<int> A(N);
    for(auto &a : A) cin >> a;

    vector<vector<int>> Rmod(N);
    vector<int> add(100000);
    for(int i=N-1; i>=0; i--) add.at(repeat2(5,A.at(i),P))++,Rmod.at(i) = add;
    
    long long answer = 0;
    for(int i=0; i<N-3; i++){
        long long a = repeat2(10,A.at(i),P);
        for(int k=i+1; k<N-2; k++){
            long long b = repeat2(9,A.at(k),P);
            for(int l=k+1; l<N-1; l++){
                long long c = repeat2(7,A.at(l),P);
                long long goal = (Q-(a+b+c)%P+P)%P;
                answer += Rmod.at(l+1).at(goal);
            }
        }
    }
    cout << answer << endl;
}
0