結果

問題 No.2709 1975 Powers
ユーザー rotti_coderrotti_coder
提出日時 2024-03-31 14:19:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 829 bytes
コンパイル時間 927 ms
コンパイル使用メモリ 85,396 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:19:34
合計ジャッジ時間 4,503 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 4 ms
6,676 KB
testcase_03 AC 131 ms
6,676 KB
testcase_04 AC 217 ms
6,676 KB
testcase_05 AC 146 ms
6,676 KB
testcase_06 AC 47 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 43 ms
6,676 KB
testcase_09 AC 146 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 6 ms
6,676 KB
testcase_12 AC 13 ms
6,676 KB
testcase_13 AC 177 ms
6,676 KB
testcase_14 AC 23 ms
6,676 KB
testcase_15 AC 26 ms
6,676 KB
testcase_16 AC 116 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 16 ms
6,676 KB
testcase_19 AC 211 ms
6,676 KB
testcase_20 AC 3 ms
6,676 KB
testcase_21 AC 41 ms
6,676 KB
testcase_22 AC 254 ms
6,676 KB
testcase_23 AC 254 ms
6,676 KB
testcase_24 AC 279 ms
6,676 KB
testcase_25 AC 254 ms
6,676 KB
testcase_26 AC 253 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long power(long long x,long long n,long long m){
  long long res=1;
  if(n>0){
    res=power(x,n/2,m);
    if(n%2==0)res=(res*res)%m;
    else res=(((res*res)%m)*x)%m;
  }
  return res;
}
int main()
{
  int n,p,q,ans=0;
  cin >> n >> p >> q;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin >> a[i];
  sort(a.begin(),a.end());
  vector<vector<int>>num;
  for(int i=0;i<n;i++){
    num.push_back({});
    num[i].emplace_back(power(10,a[i],p));
    num[i].emplace_back(power(9,a[i],p));
    num[i].emplace_back(power(7,a[i],p));
    num[i].emplace_back(power(5,a[i],p));
  }
  for(int i=0;i<n;i++)for(int j=i+1;j<n;j++)for(int k=j+1;k<n;k++)for(int ipp=k+1;ipp<n;ipp++)if((num[i][0]+num[j][1]+num[k][2]+num[ipp][3])%p==q)ans++;
  cout << ans << endl;
}
0