結果

問題 No.2709 1975 Powers
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-03-31 21:30:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 813 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 2,555 ms
コンパイル使用メモリ 207,664 KB
実行使用メモリ 65,844 KB
最終ジャッジ日時 2024-03-31 21:30:24
合計ジャッジ時間 13,342 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
65,840 KB
testcase_01 AC 105 ms
65,840 KB
testcase_02 AC 112 ms
65,844 KB
testcase_03 AC 466 ms
65,844 KB
testcase_04 AC 709 ms
65,844 KB
testcase_05 AC 513 ms
65,844 KB
testcase_06 AC 229 ms
65,844 KB
testcase_07 AC 105 ms
65,840 KB
testcase_08 AC 219 ms
65,844 KB
testcase_09 AC 535 ms
65,844 KB
testcase_10 AC 104 ms
65,840 KB
testcase_11 AC 114 ms
65,844 KB
testcase_12 AC 132 ms
65,844 KB
testcase_13 AC 535 ms
65,844 KB
testcase_14 AC 161 ms
65,844 KB
testcase_15 AC 170 ms
65,844 KB
testcase_16 AC 426 ms
65,844 KB
testcase_17 AC 105 ms
65,840 KB
testcase_18 AC 142 ms
65,844 KB
testcase_19 AC 720 ms
65,844 KB
testcase_20 AC 107 ms
65,844 KB
testcase_21 AC 211 ms
65,844 KB
testcase_22 AC 813 ms
65,844 KB
testcase_23 AC 798 ms
65,844 KB
testcase_24 AC 787 ms
65,844 KB
testcase_25 AC 812 ms
65,844 KB
testcase_26 AC 794 ms
65,844 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int siz = 2000010;

int main() {
    int n;
    long long p, q;
    cin >> n >> p >> q;
    vector<long long> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<long long> ten(siz), nine(siz), seven(siz), five(siz);
    ten[0] = nine[0] = seven[0] = five[0] = 1LL;
    for (int i = 1; i < siz; i++) {
        ten[i] = ten[i - 1] * 10LL % p;
        nine[i] = nine[i - 1] * 9LL % p;
        seven[i] = seven[i - 1] * 7LL % p;
        five[i] = five[i - 1] * 5LL % p;
    }
    sort(a.begin(), a.end());
    int 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++) {
                    long long res = (ten[a[i]] + nine[a[j]] + seven[a[k]] + five[a[l]]) % p;
                    if (res == q) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
0