結果

問題 No.2709 1975 Powers
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-03-31 15:42:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 998 bytes
コンパイル時間 2,301 ms
コンパイル使用メモリ 210,704 KB
実行使用メモリ 81,484 KB
最終ジャッジ日時 2024-03-31 15:42:58
合計ジャッジ時間 31,036 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
81,480 KB
testcase_01 AC 162 ms
81,480 KB
testcase_02 AC 183 ms
81,484 KB
testcase_03 AC 1,342 ms
81,484 KB
testcase_04 TLE -
testcase_05 AC 1,465 ms
81,484 KB
testcase_06 AC 580 ms
81,484 KB
testcase_07 AC 165 ms
81,480 KB
testcase_08 AC 547 ms
81,484 KB
testcase_09 AC 1,487 ms
81,484 KB
testcase_10 AC 164 ms
81,480 KB
testcase_11 AC 203 ms
81,484 KB
testcase_12 AC 271 ms
81,484 KB
testcase_13 AC 1,537 ms
81,484 KB
testcase_14 AC 360 ms
81,484 KB
testcase_15 AC 391 ms
81,484 KB
testcase_16 AC 1,199 ms
81,484 KB
testcase_17 AC 165 ms
81,484 KB
testcase_18 AC 300 ms
81,484 KB
testcase_19 TLE -
testcase_20 AC 175 ms
81,484 KB
testcase_21 AC 537 ms
81,484 KB
testcase_22 TLE -
testcase_23 TLE -
testcase_24 TLE -
testcase_25 TLE -
testcase_26 TLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<long long> v = {10LL, 9LL, 7LL, 5LL};
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<vector<long long>> mods(4, vector<long long>(siz, 1LL));
    for (int i = 0; i < 4; i++) {
        for (int j = 1; j < siz; j++) {
            mods[i][j] = mods[i][j - 1] * v[i] % p;
        }
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                for (int l = 0; l < n; l++) {
                    if (i < j && j < k && k < l) {
                        if ((mods[0][a[i]] + mods[1][a[j]] + mods[2][a[k]] + mods[3][a[l]]) % p == q) {
                            ans++;
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}
0