結果

問題 No.2709 1975 Powers
ユーザー namahamu0909
提出日時 2024-11-01 20:35:33
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,302 bytes
コンパイル時間 6,423 ms
コンパイル使用メモリ 338,696 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-11-01 20:35:44
合計ジャッジ時間 10,629 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 TLE * 1 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
const ll INF=9e18;

ll ruijo(ll kazu, ll jo, ll P){
    bitset<24>bit(jo);
    ll goukei=1;
    ll ima=kazu;
    for (ll a = 0; a < 24; a++){
        if(bit.test(a)){
            goukei*=ima;
            goukei%=P;
        }
        ima*=ima;
        ima%=P;

    }
    return goukei;

}

int main() {
    ll N,P,Q;
    cin>>N>>P>>Q;
    vector<ll> A (N);
    for (ll a = 0; a < N; a++){
        cin>>A[a];
    }
    sort(A.begin(),A.end());
    ll kotae=0;
    for (ll a = 0; a < N-3; a++){
        for (ll b = a+1; b < N-2; b++){
            for (ll c = b+1; c < N-1; c++){
                for (ll d = c+1; d < N; d++){
                    //cout<<A[a]<<A[b]<<A[c]<<A[d]<<endl;
                    ll nya=ruijo(10,A[a],P);
                    //cout<<nya<<endl;
                    nya%=P;
                    nya+=ruijo(9,A[b],P);
                    nya%=P;
                    nya+=ruijo(7,A[c],P);
                    nya%=P;
                    nya+=ruijo(5,A[d],P);
                    nya%=P;
                    if(nya==Q){
                        kotae++;
                    }
                }
            }
        }
    }
    cout<<kotae;
}
0