結果

問題 No.2709 1975 Powers
ユーザー eom@🩵ストeom@🩵スト
提出日時 2024-03-31 14:00:27
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 740 ms / 2,000 ms
コード長 5,290 bytes
コンパイル時間 6,055 ms
コンパイル使用メモリ 335,696 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-03-31 14:00:42
合計ジャッジ時間 14,229 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 7 ms
6,548 KB
testcase_03 AC 366 ms
6,548 KB
testcase_04 AC 633 ms
6,548 KB
testcase_05 AC 411 ms
6,548 KB
testcase_06 AC 129 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 118 ms
6,548 KB
testcase_09 AC 415 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 12 ms
6,548 KB
testcase_12 AC 33 ms
6,548 KB
testcase_13 AC 431 ms
6,548 KB
testcase_14 AC 60 ms
6,548 KB
testcase_15 AC 69 ms
6,548 KB
testcase_16 AC 325 ms
6,548 KB
testcase_17 AC 3 ms
6,548 KB
testcase_18 AC 42 ms
6,548 KB
testcase_19 AC 598 ms
6,548 KB
testcase_20 AC 5 ms
6,548 KB
testcase_21 AC 114 ms
6,548 KB
testcase_22 AC 716 ms
6,548 KB
testcase_23 AC 717 ms
6,548 KB
testcase_24 AC 740 ms
6,548 KB
testcase_25 AC 716 ms
6,548 KB
testcase_26 AC 739 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
//
using namespace atcoder;
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using vi = vector<int>;
using vll = vector<long long>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
template <typename T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
bool chmin(T &a, const T &b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
#define reps(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) reps(i, 0, n)
#define rrep(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define ALL(box) (box).begin(), (box).end()
#define all(box) (box).begin(), (box).end()
#define RALL(box) (box).rbegin(), (box).rend()
#define rall(box) (box).rbegin(), (box).rend()
ll inf=((1LL<<62)-(1LL<<31));
ll sum = 0;
ll num = 0;
int pum = 0;
ll mum = 0;
int min1 = 1000000001;
int max1 = 0;
ll min2 = inf;
ll max2 = -inf;
ll MOD1 = 1000000007;
ll MOD = 998244353;
using mint = modint998244353;
//using mint = modint1000000007;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0}; // 右、下、左、上
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy8[8] = {1, 1, 0, -1, -1, -1, 0, 1};
// sort(box.rbegin(), box.rend());
// printf("%.7Lf", n);
// reverse(t.begin(), t.end());
// unique(box.begin(), box.end());
// auto It = lower_bound(ALL(box), n);以上 4
// auto It = upper_bound(ALL(box), n);含まない上 7
// cout << box.end() - It ; 末尾までの距離
// cout << It - a.begin() ; 先頭までの距離
// auto It =box.upper_bound( k);set,multiset
// pqueue < int, vector<int>, greater<int>> q;
// priority_queue<pii, vector<pii>, greater<pii>> pq;//小さい順
// segtree<ll, op, e> seg(N);
// lazy_segtree<S, op, e, F, mapping, composition, id> seg(N);
// box.erase(unique(all(box), box.end());
// st.erase(st.find(5));
ll zaatu(vector<ll>&A){map<ll,ll>m;for(auto&&x:A)m[x]=0;ll ret = 0;for(auto&&[key,val]:m)val=ret++;for(auto&&x:A)x=m[x];return ret;}
void dei(const vector<int>& G){for(auto x:G){cout <<x<<" ";}cout <<endl;}
void del(const vector<ll>& G) {for(auto x:G){cout <<x<<" ";}cout <<endl;}
void dei2(const vector<vector<int>>& G){for(auto x:G){for(auto y:x){cout<<y<<" ";}cout <<endl;}cout <<endl;}
void del2(const vector<vector<ll>>& G) {for(auto x:G){for(auto y:x){cout<<y<<" ";}cout <<endl;}cout <<endl;}
void del2m(const vector<vector<mint>>& G) {for(auto x:G){for(auto y:x){cout<<y.val()<<" ";}cout <<endl;}cout <<endl;}
void dec2(const vector<vector<char>>& G) {for(auto x:G){for(auto y:x){cout<<y<<" ";}cout <<endl;}cout <<endl;}
void de3(const vector<vector<vector<ll>>>& G){for(auto x:G){for(auto y:x){for(auto z:y){cout<<z<<" ";}cout<<endl;}cout<<endl;}cout<<endl;}
void Gnyu(Graph& G,int mukou_0_yuukou_1){ll a,b;cin>>a>>b;a--;b--;G[a].push_back(b);if(mukou_0_yuukou_1==0){G[b].push_back(a);}}
struct edge{
    ll to;
    ll leng;
};
vector<ll> Dij(const vector<vector<edge>>& G,int first){
    int N=G.size();
    vector<ll> dist(N,inf);//最短経路を保存
    priority_queue<pll, vector<pll>, greater<pll>> pq;
    vector<bool> ok(N,false);//確定させる
    dist[first]=0;//最初の地点は0
    pq.push({dist[first],first});//最初の地点から行う
    while(!pq.empty()){
        ll n,m;
        tie(n,m)=pq.top();
        pq.pop();//取り出し、捨てる
        if(ok[m]==false){//すでに確定されてないなら
            ok[m]=true;//確定させて
            dist[m]=n;//最短経路も確定させる。
            for(auto x:G[m]){//その場所からいけるすべての場所を入れて、
                if(ok[x.to]==false){//もしまだ確定されていないなら
                    pq.push({dist[m]+x.leng,x.to});//{最短経路,その頂点を格納}
                }
            }
        }
    }
    //for(auto x:dist) cout <<x<<" ";
    //cout <<endl;
    return dist;//最短経路を返す。行けない場合はinf
}
ll MAX_MIN_K(vector<ll> box,ll K){
    sort(all(box));
    //del(box);
    int N=box.size();
    ll min3=inf;
    rep(i,N-K+1){
        min3=min(min3,abs(box[K+i-1]-box[i]));
    }
    return min3;
}
ld menseki(ld x1,ld y1,ld x2,ld y2,ld x3,ld y3){
    return abs((x2-x1)*(y3-y1)-(x3-x1)*(y2-y1))/2;
}
ld you(ld x1, ld y1, ld x2, ld y2) {
    return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
ll power(ll a, ll b, ll m) {
    ll p = a, ans = 1;
    for(int i = 0; i < 63; i++) {
        ll wari = (1LL << i);
        if((b / wari) % 2 == 1) {
            ans = (ans * p) % m;
        }
        p = (p * p) % m;
    }
    return ans;
}//a^b(mod m)を求める
int main(){
    ll N,P,Q;
    cin>>N>>P>>Q;
    vector<ll> box(N);
    rep(i,N){
        cin>>box[i];
    }sort(all(box));
    vector dp(4,vector(N,0LL));
    ll ban[]={10,9,7,5};
    rep(i,4){
        rep(j,N){
            dp[i][j]=power(ban[i],box[j],P);
        }
    }
    rep(i,N){
        reps(j,i+1,N){
            reps(k,j+1,N){
                reps(n,k+1,N){
                    if((dp[0][i]+dp[1][j]+dp[2][k]+dp[3][n]+P)%P==Q){
                        sum++;
                    }
                }
            }
        }
    }
    cout <<sum;

}
0