結果

問題 No.2709 1975 Powers
ユーザー mitanimitani
提出日時 2024-03-31 15:13:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 908 bytes
コンパイル時間 4,119 ms
コンパイル使用メモリ 231,540 KB
実行使用メモリ 10,132 KB
最終ジャッジ日時 2024-03-31 15:13:23
合計ジャッジ時間 8,541 ms
ジャッジサーバーID
(参考情報)
judge10 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,132 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1,017 ms
6,676 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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));
    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 cru=pow_mod(10,a[i])+pow_mod(9,a[j])+pow_mod(7,a[k])+pow_mod(5,a[l]);
        cru%=p;
        if(cru==q)ans++;
    }
    cout<<ans<<endl;
}
0