結果

問題 No.2709 1975 Powers
ユーザー tsunamayo123tsunamayo123
提出日時 2024-03-31 14:16:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,144 bytes
コンパイル時間 4,657 ms
コンパイル使用メモリ 266,696 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 14:17:04
合計ジャッジ時間 11,193 ms
ジャッジサーバーID
(参考情報)
judge10 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#if !__INCLUDE_LEVEL__
#include __FILE__

// using mint = modint998244353;
// using mint = modint1000000007;
using mint=modint;

void solve(){
    int N,P,Q; cin>>N>>P>>Q;
    vector<int> A(N); rep(i,0,N)cin>>A[i];
    ll ans=0;
    mint::set_mod(P);
    vector<vector<int>> five(P);
    rep(i,0,N){
        five[(mint(5).pow(A[i])).val()].pb(i);
    }
    rep(i,0,N)rep(j,i+1,N)rep(k,j+1,N){
        if(i!=j&&j!=k&&k!=i){
            mint ai=mint(10).pow(A[i]);
            mint aj=mint(9).pow(A[j]);
            mint ak=mint(7).pow(A[k]);
            mint al=Q-(ai+aj+ak);
            ans+=five[al.val()].size()-(upper_bound(all(five[al.val()]),k)-five[al.val()].begin());
        }
    }
    debug(five);
    cout<<ans<<endl;
}

#else


#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define rrep(i,l,r) for(int i=(r)-1;i>=(l);--i)
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long,long long>;
#define pb push_back
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define pqueue priority_queue
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define inr(l, x, r) (l <= x && x < r)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define INF (1<<30)-1
#define INFLL (1LL<<60)-1
#define popcount __builtin_popcount
#define UNIQUE(v) sort(v.begin(),v.end()),v.erase(unique(v.begin(),v.end()),v.end());
void yn(bool flag){if(flag)cout<<"Yes"<<'\n'; else cout<<"No"<<'\n';}
template <typename T>
bool chmax(T &a,const T& b){if(a<b){a=b;return true;}return false;}
template <typename T>
bool chmin(T &a,const T& b){if(a>b){a=b;return true;}return false;}
void solve();

#ifdef LOCAL
#  include <debug_print.hpp>
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    solve();
}

#endif
0