結果

問題 No.2709 1975 Powers
ユーザー shkiiii_shkiiii_
提出日時 2024-03-31 17:30:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,689 ms / 2,000 ms
コード長 1,750 bytes
コンパイル時間 2,435 ms
コンパイル使用メモリ 210,652 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 17:30:32
合計ジャッジ時間 21,961 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 4 ms
6,676 KB
testcase_02 AC 41 ms
6,676 KB
testcase_03 AC 930 ms
6,676 KB
testcase_04 AC 1,441 ms
6,676 KB
testcase_05 AC 1,063 ms
6,676 KB
testcase_06 AC 452 ms
6,676 KB
testcase_07 AC 5 ms
6,676 KB
testcase_08 AC 413 ms
6,676 KB
testcase_09 AC 1,088 ms
6,676 KB
testcase_10 AC 5 ms
6,676 KB
testcase_11 AC 68 ms
6,676 KB
testcase_12 AC 152 ms
6,676 KB
testcase_13 AC 1,118 ms
6,676 KB
testcase_14 AC 236 ms
6,676 KB
testcase_15 AC 290 ms
6,676 KB
testcase_16 AC 882 ms
6,676 KB
testcase_17 AC 12 ms
6,676 KB
testcase_18 AC 186 ms
6,676 KB
testcase_19 AC 1,446 ms
6,676 KB
testcase_20 AC 30 ms
6,676 KB
testcase_21 AC 404 ms
6,676 KB
testcase_22 AC 1,641 ms
6,676 KB
testcase_23 AC 1,689 ms
6,676 KB
testcase_24 AC 1,670 ms
6,676 KB
testcase_25 AC 1,660 ms
6,676 KB
testcase_26 AC 1,630 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
// #include<boost/multiprecision/cpp_int.hpp>

using namespace std;
// using namespace atcoder;
// using bint = boost::multiprecision::cpp_int;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define sz(c) ((ll)(c).size())
#define LB(A,x) (int)(lower_bound(A.begin(),A.end(),x)-A.begin())
// #define MOD 1000000007
#define MOD 998244353
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){for(int i = 0;i < v.size();i++)os<<v[i]<<(i+1!=v.size()?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.first<<" "<<p.second;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.first>>p.second;return is;}

long long modpow(long long n,long long r,int mod){
  long long res = 1;
  while(r){
    if(r & 1)res = res*n%mod;
    n = n*n%mod;
    r >>= 1;
  }
  return res;
}

int main(){
  
  ios_base::sync_with_stdio(0), cin.tie(0);
  ll n,P,Q;
  cin >> n >> P >> Q;
  vi a(n);cin >> a;
  sort(ALL(a));
  vvi modu(P);
  rep(i,n)modu[modpow(5,a[i],P)].emplace_back(i);
  ll res = 0;
  rep(i,n)rep(j,n)rep(k,n){
    if(i < j && j < k){
      ll x = modpow(10,a[i],P)+modpow(9,a[j],P)+modpow(7,a[k],P);
      x %= P;
      x = (Q-x+P)%P;
      x = sz(modu[x])-LB(modu[x],k+1);
      res += x;
    }
  }
  cout << res << "\n";
  

  return 0;
}
0