結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 4 ms
6,676 KB
testcase_02 AC 33 ms
26,496 KB
testcase_03 AC 421 ms
70,016 KB
testcase_04 AC 647 ms
78,976 KB
testcase_05 AC 488 ms
71,936 KB
testcase_06 AC 211 ms
54,656 KB
testcase_07 AC 8 ms
10,752 KB
testcase_08 AC 204 ms
53,504 KB
testcase_09 AC 522 ms
71,936 KB
testcase_10 AC 9 ms
11,136 KB
testcase_11 AC 49 ms
31,232 KB
testcase_12 AC 86 ms
39,424 KB
testcase_13 AC 508 ms
72,704 KB
testcase_14 AC 128 ms
45,696 KB
testcase_15 AC 143 ms
47,232 KB
testcase_16 AC 430 ms
67,968 KB
testcase_17 AC 16 ms
17,792 KB
testcase_18 AC 105 ms
41,728 KB
testcase_19 AC 635 ms
78,592 KB
testcase_20 AC 27 ms
23,680 KB
testcase_21 AC 218 ms
53,120 KB
testcase_22 AC 657 ms
82,176 KB
testcase_23 AC 755 ms
82,176 KB
testcase_24 AC 718 ms
82,176 KB
testcase_25 AC 754 ms
82,176 KB
testcase_26 AC 730 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;
    sort(A.begin(),A.end());

    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