結果
| 問題 |
No.2709 1975 Powers
|
| ユーザー |
mitani
|
| 提出日時 | 2024-03-31 15:13:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 908 bytes |
| コンパイル時間 | 3,434 ms |
| コンパイル使用メモリ | 232,264 KB |
| 実行使用メモリ | 10,016 KB |
| 最終ジャッジ日時 | 2024-09-30 20:25:37 |
| 合計ジャッジ時間 | 7,729 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 TLE * 1 -- * 23 |
コンパイルメッセージ
main.cpp: In function 'll pow_mod(ll, ll)':
main.cpp:23:1: warning: control reaches end of non-void function [-Wreturn-type]
23 | }
| ^
ソースコード
#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;
}
mitani