結果

問題 No.2709 1975 Powers
ユーザー rikeichanrikeichan
提出日時 2024-03-31 18:50:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 926 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 171,116 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 18:50:35
合計ジャッジ時間 9,774 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 344 ms
6,676 KB
testcase_04 AC 597 ms
6,676 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
6,676 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
6,676 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 56 ms
6,676 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 675 ms
6,676 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 674 ms
6,676 KB
testcase_26 AC 687 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];
        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);
    }



    sort(A, A+N);
    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