結果

問題 No.2709 1975 Powers
ユーザー nononnonon
提出日時 2024-03-31 14:09:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 584 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 2,379 ms
コンパイル使用メモリ 208,596 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:09:58
合計ジャッジ時間 9,662 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 15 ms
6,676 KB
testcase_03 AC 319 ms
6,676 KB
testcase_04 AC 472 ms
6,676 KB
testcase_05 AC 352 ms
6,676 KB
testcase_06 AC 146 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 135 ms
6,676 KB
testcase_09 AC 352 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 24 ms
6,676 KB
testcase_12 AC 51 ms
6,676 KB
testcase_13 AC 357 ms
6,676 KB
testcase_14 AC 83 ms
6,676 KB
testcase_15 AC 92 ms
6,676 KB
testcase_16 AC 293 ms
6,676 KB
testcase_17 AC 6 ms
6,676 KB
testcase_18 AC 63 ms
6,676 KB
testcase_19 AC 462 ms
6,676 KB
testcase_20 AC 10 ms
6,676 KB
testcase_21 AC 132 ms
6,676 KB
testcase_22 AC 560 ms
6,676 KB
testcase_23 AC 583 ms
6,676 KB
testcase_24 AC 556 ms
6,676 KB
testcase_25 AC 584 ms
6,676 KB
testcase_26 AC 571 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/math>
using namespace std;
int N,P,Q,A[200];
int p10[1<<17];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>N>>P>>Q;
    for(int i=0;i<N;i++)cin>>A[i];
    sort(A,A+N);
    long 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++)
        {
            long p9=atcoder::pow_mod(9,A[a],P);
            long p7=atcoder::pow_mod(7,A[b],P);
            long p5=atcoder::pow_mod(5,A[c],P);
            ans+=p10[((Q-p9-p7-p5)%P+P)%P];
        }
        p10[atcoder::pow_mod(10,A[a],P)]++;
    }
    cout<<ans<<endl;
}
0