結果

問題 No.2709 1975 Powers
ユーザー Hydrogen332
提出日時 2025-03-26 23:31:25
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 887 bytes
コンパイル時間 3,375 ms
コンパイル使用メモリ 277,480 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-26 23:31:37
合計ジャッジ時間 11,227 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (int i = (int)(s); i < (int)(e); ++i)
#define all(a) (a).begin(),(a).end()

ll modpow(ll a, ll n, ll m) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % m;
        a = a * a % m;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    
    int N;
    ll P, Q;
    cin >> N >> P >> Q;
    vector<ll> A(N), B(N), C(N), D(N);
    rep(i, 0, N) {
        int t;
        cin >> t;
        A[i] = modpow(10, t, P);
        B[i] = modpow(9, t, P);
        C[i] = modpow(7, t, P);
        D[i] = modpow(5, t, P);
    }
    
    ll ans = 0;
    rep(a, 0, N - 3) rep(b, a + 1, N - 2) rep(c, b + 1, N - 1) rep(d, c + 1, N) {
        if ((A[a] + B[b] + C[c] + D[d]) % P == Q) ++ans;
    }
    
    cout << ans << '\n';
}
0