結果
問題 | No.2709 1975 Powers |
ユーザー |
![]() |
提出日時 | 2024-03-31 15:33:03 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 306 ms / 2,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 2,241 ms |
コンパイル使用メモリ | 210,368 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-30 20:50:03 |
合計ジャッジ時間 | 5,988 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N, P, Q, C = 0; cin >> N >> P >> Q; vector<int> A(N); for (int &a : A) cin >> a; vector B(4, vector<int>(N)); sort(A.begin(), A.end()); 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++) { 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; }