結果

問題 No.2709 1975 Powers
ユーザー ensembleaverageensembleaverage
提出日時 2024-03-31 15:08:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 862 ms / 2,000 ms
コード長 2,054 bytes
コンパイル時間 1,821 ms
コンパイル使用メモリ 178,424 KB
実行使用メモリ 24,192 KB
最終ジャッジ日時 2024-03-31 15:08:28
合計ジャッジ時間 13,919 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 261 ms
22,400 KB
testcase_03 AC 411 ms
14,336 KB
testcase_04 AC 716 ms
20,096 KB
testcase_05 AC 566 ms
17,920 KB
testcase_06 AC 176 ms
9,472 KB
testcase_07 AC 97 ms
21,120 KB
testcase_08 AC 526 ms
22,144 KB
testcase_09 AC 647 ms
19,584 KB
testcase_10 AC 97 ms
21,376 KB
testcase_11 AC 122 ms
10,880 KB
testcase_12 AC 430 ms
24,192 KB
testcase_13 AC 779 ms
22,912 KB
testcase_14 AC 233 ms
13,056 KB
testcase_15 AC 532 ms
23,808 KB
testcase_16 AC 315 ms
12,160 KB
testcase_17 AC 99 ms
14,336 KB
testcase_18 AC 445 ms
23,808 KB
testcase_19 AC 652 ms
18,304 KB
testcase_20 AC 243 ms
23,296 KB
testcase_21 AC 527 ms
22,144 KB
testcase_22 AC 862 ms
22,400 KB
testcase_23 AC 657 ms
18,432 KB
testcase_24 AC 380 ms
12,160 KB
testcase_25 AC 657 ms
17,920 KB
testcase_26 AC 712 ms
19,712 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"

/*
#include "boost/multiprecision/cpp_int.hpp"
namespace mp = boost::multiprecision;
using i128=mp::cpp_int;
*/

using namespace std;
typedef long long ll;
typedef int64_t i64;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define drep(i,a,n) for(int i=a;i>n;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define iINF 1000000007
#define lINF 10000000000007
#define llINF 4000000000000000007
#define all(x) x.begin(),x.end()
#define so(x) sort(all(x))
#define re(x) reverse(all(x))
const double PI = acos(-1);

//累乗余り
ll modexpo(ll x,ll n,ll m){
    if(x==0) return 0;
    x%=m;
    ll ans=1;
    ll change=x;
    while(n>0){
        if(n%2==1){ans*=change; ans%=m;}
        change*=change;
        change%=m;
        n/=2;
    }
    return ans;
}

int main(){
    ll n,p,q; cin>>n>>p>>q;
    vll a(n); rep(i,0,n) cin>>a[i];
    so(a);
    
    vvvll dp(2,vvll(p,vll(5)));
    dp[0][0][0]=1;
    
    rep(i,1,n+1){
        ll I=i%2,J=(i+1)%2;
        vll mod(5);
        mod[1]=modexpo(10,a[i-1],p);
        mod[2]=modexpo(9,a[i-1],p);
        mod[3]=modexpo(7,a[i-1],p);
        mod[4]=modexpo(5,a[i-1],p);
        rep(j,0,p){
            rep(k,0,5){
                dp[I][j][k]=dp[J][j][k];
            }
            dp[I][j][1]+=dp[J][(j-mod[1]+p)%p][0];
            dp[I][j][2]+=dp[J][(j-mod[2]+p)%p][1];
            dp[I][j][3]+=dp[J][(j-mod[3]+p)%p][2];
            dp[I][j][4]+=dp[J][(j-mod[4]+p)%p][3];
        }
        /*rep(j,0,p){
            rep(k,0,5) cout<<dp[I][j][k]<<" ";
            cout<<endl;
        }
        cout<<endl<<endl;*/
    }
    cout<<dp[n%2][q][4]<<endl;
    
}
0