結果

問題 No.2709 1975 Powers
ユーザー mitanimitani
提出日時 2024-03-31 14:27:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,130 bytes
コンパイル時間 3,766 ms
コンパイル使用メモリ 234,516 KB
実行使用メモリ 287,212 KB
最終ジャッジ日時 2024-03-31 14:27:56
合計ジャッジ時間 8,717 ms
ジャッジサーバーID
(参考情報)
judge11 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 85 ms
86,704 KB
testcase_03 AC 166 ms
142,920 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 26 ms
28,336 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 26 ms
30,120 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 88 ms
80,832 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 30 ms
33,448 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 77 ms
80,180 KB
testcase_21 WA -
testcase_22 AC 317 ms
287,212 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 252 ms
220,460 KB
testcase_26 AC 275 ms
246,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'll pow_mod(ll, ll)':
main.cpp:22:1: warning: control reaches end of non-void function [-Wreturn-type]
   22 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#include <atcoder/all>
using namespace atcoder;
//using mint=static_modint<998244353>;
using mint=static_modint<1000000007>;

ll mod;

ll pow_mod(ll n,ll k){
    if(k==0)return 1;
    if(k%2==1)return pow_mod(n,k-1)*n%mod;
    if(k%2==0){
        ll t=pow_mod(n,k/2);
        return t*t%mod;
    }
}

int main(){
	ll n,p,q;cin>>n>>p>>q;
    mod=p;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(all(a));


    vector<vector<ll>> f(n,vector<ll>(p));
    vector<vector<ll>> g(n+1,vector<ll>(p));
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        f[j][(pow_mod(10,a[i])+pow_mod(9,a[j]))%p]++;
    }
    for(int i=0;i<n;i++)for(int j=i+1;j<n;j++){
        g[i][(pow_mod(7,a[i])+pow_mod(5,a[j]))%p]++;
    }

    for(int i=0;i<n;i++)rep(j,p)g[i+1][j]+=g[i][j];

    ll ans=0;
    for(int i=0;i<n;i++)for(int j=0;j<p;j++){
        ll mo=q-j;
        while(mo<0)mo+=q;
        ans+=f[i][j]*(g[n][mo]-g[i][mo]);
    }
    cout<<ans<<endl;
}
0