結果

問題 No.2709 1975 Powers
ユーザー MMMM
提出日時 2024-03-31 13:56:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 355 ms / 2,000 ms
コード長 1,225 bytes
コンパイル時間 4,004 ms
コンパイル使用メモリ 231,772 KB
実行使用メモリ 34,584 KB
最終ジャッジ日時 2024-03-31 13:56:25
合計ジャッジ時間 9,112 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
34,580 KB
testcase_01 AC 42 ms
34,580 KB
testcase_02 AC 46 ms
34,580 KB
testcase_03 AC 186 ms
34,584 KB
testcase_04 AC 280 ms
34,584 KB
testcase_05 AC 204 ms
34,584 KB
testcase_06 AC 93 ms
34,584 KB
testcase_07 AC 44 ms
34,580 KB
testcase_08 AC 88 ms
34,584 KB
testcase_09 AC 203 ms
34,584 KB
testcase_10 AC 43 ms
34,580 KB
testcase_11 AC 70 ms
34,584 KB
testcase_12 AC 56 ms
34,584 KB
testcase_13 AC 211 ms
34,584 KB
testcase_14 AC 66 ms
34,584 KB
testcase_15 AC 69 ms
34,584 KB
testcase_16 AC 170 ms
34,584 KB
testcase_17 AC 44 ms
34,580 KB
testcase_18 AC 59 ms
34,584 KB
testcase_19 AC 280 ms
34,584 KB
testcase_20 AC 46 ms
34,580 KB
testcase_21 AC 88 ms
34,584 KB
testcase_22 AC 347 ms
34,584 KB
testcase_23 AC 355 ms
34,584 KB
testcase_24 AC 326 ms
34,584 KB
testcase_25 AC 328 ms
34,584 KB
testcase_26 AC 329 ms
34,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define ld long double
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
const ll mod = 998244353;
// using Graph = vector<vector<pair<int,int>>>;
using Graph = vector<vector<int>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int main(){
  // input
  int N,P,Q; cin >> N >> P >> Q;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  // prep
  const int M = int(2e6+1);
  sort(A.begin(),A.end());
  vector<int> t(M,1), n(M,1), s(M,1), f(M,1);
  for(int i = 0; i < M; i++){
    t[i+1] = (t[i] * 10) % P;
    n[i+1] = (n[i] * 9) % P;
    s[i+1] = (s[i] * 7) % P;
    f[i+1] = (f[i] * 5) % P;
  }
  
  // solve
  int ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = i+1; j < N; j++){
      if(A[i] == A[j]) continue;
      for(int k = j+1; k < N; k++){
        if(A[k] == A[j]) continue;
        for(int l = k+1; l < N; l++){
          if(A[k] == A[l]) continue;
          
          int tmp = t[A[i]] + n[A[j]] + s[A[k]] + f[A[l]];
          if(tmp % P == Q) ans++;
        }
      }
    }
  }
  
  cout << ans << endl;
}
0