結果

問題 No.2709 1975 Powers
ユーザー ooaiu
提出日時 2024-07-04 03:11:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 966 ms / 2,000 ms
コード長 1,025 bytes
コンパイル時間 5,411 ms
コンパイル使用メモリ 315,516 KB
実行使用メモリ 190,820 KB
最終ジャッジ日時 2024-07-04 03:11:32
合計ジャッジ時間 21,047 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#ifdef LOCAL
#include <algo/debug.h>
#else
#define debug(...) void(0)
#endif
#include<atcoder/all>
using namespace atcoder;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N, P, Q; cin >> N >> P >> Q;
    vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    const ll n = 2 * 1'000'000;
    vector<vector<ll>> rec(11, vector<ll>(n + 1, 1));
    for(int i = 5; i <= 10; i++) {
        for(int j = 0; j < n; j++) {
            rec[i][j + 1] = (rec[i][j] * i) % P;
        }
    }
    ll 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++) {
                for(int l = k + 1; l < N; l++) {
                    ll t = rec[10][A[i]] + rec[9][A[j]] + rec[7][A[k]] + rec[5][A[l]]; t %= P;
                    if(t == Q) ans++;
                }
            }
        }
    }
    cout << ans << endl;
}
0