結果

問題 No.2709 1975 Powers
ユーザー mitanimitani
提出日時 2024-03-31 15:17:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 826 ms / 2,000 ms
コード長 1,204 bytes
コンパイル時間 3,974 ms
コンパイル使用メモリ 231,912 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 15:17:39
合計ジャッジ時間 12,844 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 8 ms
6,676 KB
testcase_03 AC 407 ms
6,676 KB
testcase_04 AC 679 ms
6,676 KB
testcase_05 AC 457 ms
6,676 KB
testcase_06 AC 143 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 129 ms
6,676 KB
testcase_09 AC 459 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 13 ms
6,676 KB
testcase_12 AC 36 ms
6,676 KB
testcase_13 AC 478 ms
6,676 KB
testcase_14 AC 67 ms
6,676 KB
testcase_15 AC 77 ms
6,676 KB
testcase_16 AC 360 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 45 ms
6,676 KB
testcase_19 AC 661 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 127 ms
6,676 KB
testcase_22 AC 795 ms
6,676 KB
testcase_23 AC 822 ms
6,676 KB
testcase_24 AC 797 ms
6,676 KB
testcase_25 AC 800 ms
6,676 KB
testcase_26 AC 826 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'll pow_mod(ll, ll)':
main.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
   23 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#include <atcoder/all>
using namespace atcoder;
//using mint=static_modint<998244353>;
using mint=static_modint<1000000007>;


ll mod;
//繰り返し二乗法 n^k modはグローバルに
ll pow_mod(ll n,ll k){
    if(k==0)return 1;
    if(k%2==1)return pow_mod(n,k-1)*n%mod;
    if(k%2==0){
        ll t=pow_mod(n,k/2);
        return t*t%mod;
    }
}

int main(){
	ll n,p,q;cin>>n>>p>>q;
    mod=p;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));
    vector<ll> mod10(n,-1),mod9(n,-1),mod7(n,-1),mod5(n,-1);
    ll ans=0;
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++)for(int l=k+1;l<n;l++){
        ll x,y,z,w;
        if(mod10[i]==-1)mod10[i]=pow_mod(10,a[i]);
        if(mod9[j]==-1)mod9[j]=pow_mod(9,a[j]);
        if(mod7[k]==-1)mod7[k]=pow_mod(7,a[k]);
        if(mod5[l]==-1)mod5[l]=pow_mod(5,a[l]);
        x=mod10[i];
        y=mod9[j];
        z=mod7[k];
        w=mod5[l];
        ll cru=x+y+z+w;
        cru%=p;
        if(cru==q)ans++;
    }
    cout<<ans<<endl;
}
0