結果

問題 No.2709 1975 Powers
ユーザー a1048576a1048576
提出日時 2024-03-31 13:47:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 773 bytes
コンパイル時間 4,027 ms
コンパイル使用メモリ 232,384 KB
実行使用メモリ 68,144 KB
最終ジャッジ日時 2024-03-31 13:47:24
合計ジャッジ時間 8,230 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 104 ms
65,840 KB
testcase_01 AC 103 ms
65,840 KB
testcase_02 AC 107 ms
68,016 KB
testcase_03 AC 125 ms
67,120 KB
testcase_04 AC 142 ms
67,760 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 106 ms
67,888 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 106 ms
67,888 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 110 ms
66,992 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 170 ms
68,016 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 141 ms
67,504 KB
testcase_26 AC 139 ms
67,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all> 
using mint = atcoder::modint998244353;
#define int long long
signed main() {
  int n,p,q;
  cin >> n >> p >> q;
  int m = 2e6+1;
  vector<int> a(m,1), b(m,1), c(m,1), d(m,1);
  for(int i = 0; i < m-1; i++) {
    a[i+1] = a[i]*10%p;
    b[i+1] = b[i]*9%p;
    c[i+1] = c[i]*7%p;
    d[i+1] = d[i]*5%p;
  }
  vector<int> e(n,0);
  vector<vector<int>> f(p);
  for(int i = 0; i < n; i++) {
    cin >> e[i];
    f[d[e[i]]].push_back(i);
  }
  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 z = (a[e[i]]+b[e[j]]+c[e[k]])%p;
    z = (q-z+p)%p;
    int g = f[z].end()-upper_bound(f[z].begin(),f[z].end(),k);
    ans+=g;
  }
  cout << ans << endl;
}
0