結果

問題 No.2709 1975 Powers
ユーザー a1048576a1048576
提出日時 2024-04-07 13:02:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 270 ms / 2,000 ms
コード長 777 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 176,740 KB
実行使用メモリ 208,820 KB
最終ジャッジ日時 2024-04-07 13:02:19
合計ジャッジ時間 7,969 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
65,840 KB
testcase_01 AC 106 ms
65,840 KB
testcase_02 AC 142 ms
108,340 KB
testcase_03 AC 202 ms
136,244 KB
testcase_04 AC 259 ms
186,164 KB
testcase_05 AC 214 ms
161,588 KB
testcase_06 AC 143 ms
95,924 KB
testcase_07 AC 116 ms
79,024 KB
testcase_08 AC 195 ms
155,572 KB
testcase_09 AC 255 ms
171,444 KB
testcase_10 AC 117 ms
79,920 KB
testcase_11 AC 123 ms
86,068 KB
testcase_12 AC 169 ms
138,036 KB
testcase_13 AC 253 ms
195,380 KB
testcase_14 AC 144 ms
105,140 KB
testcase_15 AC 186 ms
151,732 KB
testcase_16 AC 197 ms
120,244 KB
testcase_17 AC 118 ms
81,328 KB
testcase_18 AC 177 ms
141,108 KB
testcase_19 AC 244 ms
173,108 KB
testcase_20 AC 139 ms
105,012 KB
testcase_21 AC 195 ms
154,932 KB
testcase_22 AC 270 ms
208,820 KB
testcase_23 AC 258 ms
178,996 KB
testcase_24 AC 213 ms
132,148 KB
testcase_25 AC 253 ms
174,900 KB
testcase_26 AC 244 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];
  sort(a.begin(),a.end());
  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