結果

問題 No.2709 1975 Powers
ユーザー rotti_coderrotti_coder
提出日時 2024-03-31 13:47:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 608 bytes
コンパイル時間 829 ms
コンパイル使用メモリ 82,944 KB
実行使用メモリ 13,352 KB
最終ジャッジ日時 2024-03-31 13:47:23
合計ジャッジ時間 5,057 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,352 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 894 ms
6,548 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます

ソースコード

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());
  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((power(10,a[i],p)+power(9,a[j],p)+power(7,a[k],p)+power(5,a[ipp],p))%p==q)ans++;
  cout << ans << endl;
}
0