結果
問題 |
No.2709 1975 Powers
|
ユーザー |
![]() |
提出日時 | 2024-03-31 15:24:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 819 bytes |
コンパイル時間 | 1,903 ms |
コンパイル使用メモリ | 198,444 KB |
最終ジャッジ日時 | 2025-02-20 17:53:18 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 9 WA * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, P, Q, C = 0; cin >> N >> P >> Q; vector<int> A(N); vector B(4, vector<int>(N)); auto pow = [&](long long x, long long n) { long long ret = 1; while (n) { if (n & 1) ret = ret * x % P; x = x * x % P; n = n >> 1; } return ret; }; for (int i = 0; i < N; i++) { cin >> A.at(i); B.at(0).at(i) = pow(10, A.at(i)); B.at(1).at(i) = pow(9, A.at(i)); B.at(2).at(i) = pow(7, A.at(i)); B.at(3).at(i) = pow(5, A.at(i)); } for (int i = 0; i < N - 3; i++) for (int j = i + 1; j < N - 2; j++) for (int k = j + 1; k < N - 1; k++) for (int l = k + 1; l < N; l++) if ((B.at(0).at(i) + B.at(1).at(j) + B.at(2).at(k) + B.at(3).at(l)) % P == Q) C++; cout << C << endl; }