結果

問題 No.2709 1975 Powers
ユーザー littlegirl112littlegirl112
提出日時 2024-03-31 13:41:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 808 ms / 2,000 ms
コード長 1,179 bytes
コンパイル時間 2,698 ms
コンパイル使用メモリ 208,308 KB
実行使用メモリ 65,868 KB
最終ジャッジ日時 2024-03-31 13:41:28
合計ジャッジ時間 13,040 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
65,860 KB
testcase_01 AC 98 ms
65,860 KB
testcase_02 AC 105 ms
65,868 KB
testcase_03 AC 493 ms
65,868 KB
testcase_04 AC 734 ms
65,868 KB
testcase_05 AC 527 ms
65,868 KB
testcase_06 AC 229 ms
65,868 KB
testcase_07 AC 100 ms
65,860 KB
testcase_08 AC 216 ms
65,868 KB
testcase_09 AC 505 ms
65,868 KB
testcase_10 AC 99 ms
65,860 KB
testcase_11 AC 108 ms
65,868 KB
testcase_12 AC 128 ms
65,868 KB
testcase_13 AC 557 ms
65,868 KB
testcase_14 AC 154 ms
65,868 KB
testcase_15 AC 164 ms
65,868 KB
testcase_16 AC 412 ms
65,868 KB
testcase_17 AC 101 ms
65,864 KB
testcase_18 AC 137 ms
65,868 KB
testcase_19 AC 697 ms
65,868 KB
testcase_20 AC 101 ms
65,868 KB
testcase_21 AC 213 ms
65,868 KB
testcase_22 AC 780 ms
65,868 KB
testcase_23 AC 783 ms
65,868 KB
testcase_24 AC 781 ms
65,868 KB
testcase_25 AC 782 ms
65,868 KB
testcase_26 AC 808 ms
65,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
template <class T = ll>
using vc = vector<T>;
template <class T = ll>
using vvc = vc<vc<T>>;
void solve();
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll t = 1;
    // cin >> t;
    for (int i = 1; i <= t; i++) solve();
    return 0;
}
#define rep(i, a, b) for (ll i = (a); i < (b); i++)
ll dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0};
void solve() {
    ll n, p, q;
    cin >> n >> p >> q;
    vc<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(a.begin(), a.end());
    const ll N = 2e6;
    vc<ll> pow10(N + 1), pow9(N + 1), pow7(N + 1), pow5(N + 1);
    pow10[0] = 1, pow9[0] = 1, pow7[0] = 1, pow5[0] = 1;
    rep(i, 1, N + 1) {
        pow10[i] = pow10[i - 1] * 10 % p;
        pow9[i] = pow9[i - 1] * 9 % p;
        pow7[i] = pow7[i - 1] * 7 % p;
        pow5[i] = pow5[i - 1] * 5 % p;
    }
    ll res = 0;
    rep(i, 0, n) rep(j, i + 1, n) rep(k, j + 1, n) rep(l, k + 1, n) {
        ll num = pow10[a[i]] + pow9[a[j]] + pow7[a[k]] + pow5[a[l]];
        if (num % p == q) res++;
    }
    cout << res << endl;
}
0