結果

問題 No.2709 1975 Powers
ユーザー なーなー
提出日時 2024-03-31 14:49:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,670 bytes
コンパイル時間 1,919 ms
コンパイル使用メモリ 178,308 KB
実行使用メモリ 75,264 KB
最終ジャッジ日時 2024-03-31 14:49:42
合計ジャッジ時間 9,130 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 32 ms
24,704 KB
testcase_03 AC 314 ms
38,912 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 8 ms
9,984 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 8 ms
10,368 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 564 ms
75,264 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 571 ms
58,240 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
// #include <atcoder/lazysegtree>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define printYN(check) cout << ((check)? "Yes" : "No") << endl
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define NUM 998244353
#define IMAX INT_MAX
#define LMAX LONG_MAX
using namespace std;
using namespace atcoder;
using mint = modint;
// using mint = modint998244353;
// using mint = modint1000000007;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using tii = tuple<int, int, int>;
using mii = map<int, int>;
// using Graph = vvi;
// Graph graph(n);
// vi dx = {-1, 0, 1, -1, 1, -1,  0, 1};
// vi dy = { 1, 1, 1,  0, 0, -1, -1,-1};

template<typename T> bool chmax(T &a, T b) { return ((a < b) ? (a = b, true) : (false)); }
template<typename T> bool chmin(T &a, T b) { return ((a > b) ? (a = b, true) : (false)); }

// snippet -> {UnionFind, dfs_reculsive, dfs_stack, is_prime, mypow, print_array, 
//             bfs_queue, digsum, binary_search, gcd, Dijkstra, bitsearch,
//             next_combination, binomial}
// -------------------------------------------------------------------------

int main() {
    int n, p, q;
    cin >> n >> p >> q;
    vi A(n);
    rep(i, n) cin >> A[i];
    sort(all(A));
    modint::set_mod(p);
    vector<vector<int>> b(n+1, vi(p, 0));
    rep(i, n) {
        rep(j, p) {
            b[i+1][j] = b[i][j];
        }
        mint d = 5;
        d = d.pow(A[i]);
        b[i+1][d.val()]++;
    }
    // rep(i, n) {
    //     mint d = 5;
    //     cerr << d.pow(A[i]).val() << " ";
    // }
    // cerr << endl;

    // rep(i, p) {
    //     mint d = 5;
    //     cerr << b[5][i] << " ";
    // }
    // cerr << endl;

    mint t = q;
    int ans = 0;
    rep(i, n-3) {
        rep2(j, i+1, n-2) {
            rep2(k, j+1, n-1) {
                mint ta = 10;
                mint tb = 9;
                mint tc = 7;
                t -= ta.pow(A[i]);
                t -= tb.pow(A[j]);
                t -= tc.pow(A[k]);
                // cerr << i << " " << j << " " << k << " " << t.val() << endl;
                ans += (b[n][t.val()] - b[k][t.val()]);
                // if(b[n][t.val()] - b[k][t.val()] > 0) {
                //     cerr << t.val() << " " << b[n][t.val()] << " " << b[k][t.val()] << endl;
                // }
            }
        }
    }
    cout << ans << endl;
    return 0;
}
0