結果

問題 No.2709 1975 Powers
コンテスト
ユーザー Rumain831
提出日時 2026-08-25 04:17:13
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 775 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,248 ms
コンパイル使用メモリ 187,296 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-08-25 04:17:21
合計ジャッジ時間 7,748 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other RE * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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<=10; 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; 
}
0