結果

問題 No.2709 1975 Powers
ユーザー a1048576a1048576
提出日時 2024-04-07 13:01:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 750 bytes
コンパイル時間 1,758 ms
コンパイル使用メモリ 173,544 KB
実行使用メモリ 208,820 KB
最終ジャッジ日時 2024-04-07 13:01:23
合計ジャッジ時間 8,188 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
65,840 KB
testcase_01 AC 106 ms
65,840 KB
testcase_02 AC 144 ms
108,340 KB
testcase_03 AC 199 ms
136,244 KB
testcase_04 AC 292 ms
186,164 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 118 ms
79,024 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 117 ms
79,920 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 151 ms
105,140 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 267 ms
208,820 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 253 ms
174,900 KB
testcase_26 AC 260 ms
188,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int n,mod,f;
  cin >> n >> mod >> f;
  vector<int> a(n);
  vector<int> p(2e6+1,1), q(2e6+1,1), r(2e6+1,1), s(2e6+1,1);
  for(int i = 0; i < 2e6; i++) {
    p[i+1] = p[i]*10%mod;
    q[i+1] = q[i]*9%mod;
    r[i+1] = r[i]*7%mod;
    s[i+1] = s[i]*5%mod;
  }
  for(int i = 0; i < n; i++) cin >> a[i];
  vector<vector<int>> g(n+1,vector<int>(mod,0));
  for(int i = n-1; i >= 0; i--) {
    g[i][s[a[i]]]++;
    for(int j = 0; j < mod; j++) g[i][j]+=g[i+1][j];
  }
  int 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++) {
    int x = (f-p[a[i]]-q[a[j]]-r[a[k]]+mod*mod)%mod;
    ans+=g[k+1][x];
  }
  cout << ans << endl;
}
0