結果

問題 No.2709 1975 Powers
ユーザー rikeichanrikeichan
提出日時 2024-03-31 18:53:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 700 ms / 2,000 ms
コード長 958 bytes
コンパイル時間 1,659 ms
コンパイル使用メモリ 171,108 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 18:53:35
合計ジャッジ時間 9,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 6 ms
6,676 KB
testcase_03 AC 341 ms
6,676 KB
testcase_04 AC 596 ms
6,676 KB
testcase_05 AC 387 ms
6,676 KB
testcase_06 AC 120 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 110 ms
6,676 KB
testcase_09 AC 412 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 11 ms
6,676 KB
testcase_12 AC 30 ms
6,676 KB
testcase_13 AC 403 ms
6,676 KB
testcase_14 AC 56 ms
6,676 KB
testcase_15 AC 65 ms
6,676 KB
testcase_16 AC 304 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 38 ms
6,676 KB
testcase_19 AC 586 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 107 ms
6,676 KB
testcase_22 AC 698 ms
6,676 KB
testcase_23 AC 677 ms
6,676 KB
testcase_24 AC 700 ms
6,676 KB
testcase_25 AC 673 ms
6,676 KB
testcase_26 AC 700 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;


long long modpow(long long x, long long A, long long mod){
    long long res=1;
    while (A > 0){
        if (A&1) res = res * x % mod;
        x = x * x % mod;
        A >>= 1;
    }
    return res;
}

int main(){
    long long N, P, Q;
    cin >> N >> P >> Q;
    long long A[N];
    long long array[4][N];
    for (int i=0; i<N; ++i){
        cin >> A[i];
    }
    sort(A, A+N);
    for (int i=0; i<N; ++i){
        array[0][i] = modpow(10, A[i], P);
        array[1][i] = modpow(9, A[i], P);
        array[2][i] = modpow(7, A[i], P);
        array[3][i] = modpow(5, A[i], P);
    }
    int ans=0;
    for (int i=0; i<N-3; ++i){
        for (int j=i+1; j<N-2; ++j){
            for (int k=j+1; k<N-1; ++k){
                for (int l=k+1; l<N; ++l){
                    if ((array[0][i]+array[1][j]+array[2][k]+array[3][l])%P==Q){ans++;}
                }
            }
        }
    }
    cout << ans;
}
0