結果
| 問題 | No.2709 1975 Powers |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-25 04:17:43 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 250 ms / 2,000 ms |
| + 537µs | |
| コード長 | 776 bytes |
| 記録 | |
| コンパイル時間 | 1,301 ms |
| コンパイル使用メモリ | 187,552 KB |
| 実行使用メモリ | 39,280 KB |
| 最終ジャッジ日時 | 2026-08-25 04:17:52 |
| 合計ジャッジ時間 | 6,769 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using vc = vector<int>;
using ll = long long;
int cnt[26];
int main(void){
int n, p, q; cin >> n >> p >> q;
vector<int> a(n);
int x[4]={10, 9, 7, 5};
vector pow(4, vector<int>{1});
for(int i=0; i<4; i++){
for(int j=1; j<=2e6; j++){
int y=pow[i].back();
y=(y*x[i])%p;
pow[i].push_back(y);
}
}
for(auto&x:a) cin >> x;
sort(begin(a), end(a));
int ans=0;
auto dfs=[&](auto dfs, int step, int id, int now=0){
if(step==4){
if(now==q) ans++;
return;
}
for(int i=id; i<n-3+step; i++){
int nxt=(now+pow[step][a[i]])%p;
dfs(dfs, step+1, i+1, nxt);
}
return;
};
dfs(dfs, 0, 0);
cout << ans << endl;
return 0;
}