結果

問題 No.2709 1975 Powers
ユーザー Nzt3Nzt3
提出日時 2024-03-31 14:13:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 698 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 213,352 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-03-31 14:13:51
合計ジャッジ時間 24,657 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 42 ms
6,676 KB
testcase_03 AC 1,020 ms
6,676 KB
testcase_04 AC 1,626 ms
6,676 KB
testcase_05 AC 1,174 ms
6,676 KB
testcase_06 AC 521 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 508 ms
8,704 KB
testcase_09 AC 1,289 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 76 ms
6,676 KB
testcase_12 AC 190 ms
6,912 KB
testcase_13 AC 1,406 ms
9,344 KB
testcase_14 AC 264 ms
6,676 KB
testcase_15 AC 302 ms
6,676 KB
testcase_16 AC 1,018 ms
6,676 KB
testcase_17 AC 12 ms
6,676 KB
testcase_18 AC 226 ms
8,192 KB
testcase_19 AC 1,748 ms
7,936 KB
testcase_20 AC 33 ms
6,676 KB
testcase_21 AC 543 ms
8,704 KB
testcase_22 AC 1,752 ms
6,676 KB
testcase_23 TLE -
testcase_24 AC 1,970 ms
6,676 KB
testcase_25 AC 1,868 ms
6,676 KB
testcase_26 AC 1,780 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll MOD;
namespace Lib{
  ll modpow(ll a,ll n){
    long long ret=1,t=a;
    while(n>0){
      if(n&1)ret=ret*t%MOD;
      t=t*t%MOD;
      n/=2;
    }
    return ret;
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N,P,Q;
  cin>>N>>P>>Q;
  MOD=P;
  vector A(N,0);
  for(int &i:A)cin>>i;
  sort(A.begin(),A.end());
  map<ll,int>cnt;
  ll ans=0;
  for(int c=N-1;c>=0;c--){
    for(int a=0;a<c;a++){
      for(int b=a+1;b<c;b++){
        ll x=Lib::modpow(10,A[a])+Lib::modpow(9,A[b])+Lib::modpow(7,A[c]);
        ans+=cnt[((Q-x)%P+P)%P];
      }
    }
    cnt[Lib::modpow(5,A[c])]+=1;
  }
  cout<<ans<<'\n';
}
0