結果
| 問題 |
No.2709 1975 Powers
|
| コンテスト | |
| ユーザー |
k82b
|
| 提出日時 | 2024-03-31 13:58:44 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,331 bytes |
| コンパイル時間 | 3,780 ms |
| コンパイル使用メモリ | 213,064 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-30 18:43:57 |
| 合計ジャッジ時間 | 8,289 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | RE * 25 |
ソースコード
import std, core.bitop;
bool chmin(T)(ref T SE, T MI) { if (SE > MI) { SE = MI; return true; } else { return false; } }
bool chmax(T)(ref T SE, T MI) { if (SE < MI) { SE = MI; return true; } else { return false; } }
int lowerBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] < MI ? lo : hi) = mid; } return hi; }
int upperBound(T)(T[] SE, T MI) { int lo = -1, hi = cast(int)(SE.length); while (hi - lo > 1) { int mid = lo + hi >> 1; (SE[mid] > MI ? hi : lo) = mid; } return hi; }
void main() {
int N, P, Q;
readf("%s %s %s\n", N, P, Q);
auto A = readln.chomp.split.to!(int[]);
A.sort;
auto p10 = new int[202020];
p10[0] = 1;
foreach (i; 1 .. 202020) {
p10[i] = p10[i - 1] * 10 % P;
}
auto p9 = new int[202020];
p9[0] = 1;
foreach (i; 1 .. 202020) {
p9[i] = p9[i - 1] * 9 % P;
}
auto p7 = new int[202020];
p7[0] = 1;
foreach (i; 1 .. 202020) {
p7[i] = p7[i - 1] * 7 % P;
}
auto p5 = new int[202020];
p5[0] = 1;
foreach (i; 1 .. 202020) {
p5[i] = p5[i - 1] * 5 % P;
}
auto cnt = new int[P];
foreach (i; 0 .. N) {
++cnt[p5[A[i]]];
}
int ans;
foreach (i; 0 .. N) {
--cnt[p5[A[i]]];
foreach (j; 0 .. i) {
foreach (k; 0 .. j) {
ans += cnt[(Q - (p10[A[k]] + p9[A[j]] + p7[A[i]]) % P + P) % P];
}
}
}
ans.writeln;
}
k82b