結果

問題 No.2709 1975 Powers
ユーザー GOTKAKOGOTKAKO
提出日時 2024-03-31 15:08:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,155 bytes
コンパイル時間 2,470 ms
コンパイル使用メモリ 208,440 KB
実行使用メモリ 82,176 KB
最終ジャッジ日時 2024-03-31 15:08:57
合計ジャッジ時間 11,563 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,548 KB
testcase_01 AC 4 ms
6,548 KB
testcase_02 AC 33 ms
26,496 KB
testcase_03 AC 415 ms
70,016 KB
testcase_04 AC 627 ms
78,976 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 8 ms
10,752 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 8 ms
11,136 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 122 ms
45,696 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 668 ms
82,176 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 748 ms
82,176 KB
testcase_26 AC 672 ms
82,176 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a;
        while(b){if(b&1) ret *= p; p *= p; b >>= 1;}
        return ret;
    };
 
    mint operator-(){return mint(0)-mint(v);}
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){return v == b.v;}
    bool operator!=(mint b){return v != b.v;}
    bool operator>(mint b) {return v >  b.v;}
    bool operator>=(mint b){return v >= b.v;}
    bool operator<(mint b) {return v <  b.v;}
    bool operator<=(mint b){return v <= b.v;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};			

int main() {
    int N,Q; cin >> N >> mod >> Q;
    vector<int> A(N);
    for(auto &a : A) cin >> a;

    vector<vector<int>> Rmod(N);
    vector<int> add(100000);
    for(int i=N-1; i>=0; i--) add.at(mint(5).pow(A.at(i)).v)++,Rmod.at(i) = add;

    int answer = 0;
    for(int i=0; i<N; i++){
        mint a = mint(10).pow(A.at(i));
        for(int k=i+1; k<N; k++){
            mint b = mint(9).pow(A.at(k));
            for(int l=k+1; l<N-1; l++){
                mint c = mint(7).pow(A.at(l));
                int now = (Q-(a+b+c).v+mod)%mod;
                answer += Rmod.at(l+1).at(now);
            }
        }
    }
    cout << answer << endl;
}
0