結果

問題 No.2709 1975 Powers
ユーザー ku_senjanku_senjan
提出日時 2024-03-31 13:56:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 1,501 bytes
コンパイル時間 2,400 ms
コンパイル使用メモリ 212,872 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-31 13:56:59
合計ジャッジ時間 4,182 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 47 ms
6,676 KB
testcase_04 AC 76 ms
6,676 KB
testcase_05 AC 52 ms
6,676 KB
testcase_06 AC 18 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 17 ms
6,676 KB
testcase_09 AC 53 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 6 ms
6,676 KB
testcase_13 AC 55 ms
6,676 KB
testcase_14 AC 10 ms
6,676 KB
testcase_15 AC 10 ms
6,676 KB
testcase_16 AC 42 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 7 ms
6,676 KB
testcase_19 AC 75 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 16 ms
6,676 KB
testcase_22 AC 89 ms
6,676 KB
testcase_23 AC 90 ms
6,676 KB
testcase_24 AC 90 ms
6,676 KB
testcase_25 AC 89 ms
6,676 KB
testcase_26 AC 90 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
template<class T> using graph=vector<vector<T>>;
template<class T> using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
constexpr int INF32=INT_MAX/2;
constexpr ll INF64=1LL<<60;
constexpr array<int,4> DX4={0,1,0,-1};
constexpr array<int,4> DY4={-1,0,1,0};
constexpr array<int,8> DX8={0,1,1,1,0,-1,-1,-1};
constexpr array<int,8> DY8={-1,-1,0,1,1,1,0,-1};
inline int popcnt(ll n){return __builtin_popcountll(n);}
template<class T> inline bool chmax(T& a,const T& b){return a<b?a=b,true:false;}
template<class T> inline bool chmin(T& a,const T& b){return b<a?a=b,true:false;}
#define rep(i,s,n) for(ll i=(ll)(s);i<(ll)(n);i++)
#define rrep(i,s,n) for(ll i=(ll)(s);i>=(ll)(n);i--)
void _main();
int main(){
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(16);
	_main();
}

#include <atcoder/modint>
using atcoder::modint;

void _main(){
	int N, P, Q; cin >> N >> P >> Q;
	vector<ll> A(N); rep(i,0,N) cin >> A[i];

	sort(A.begin(), A.end());

	modint::set_mod(P);

	vector<modint> pow10(N), pow9(N), pow7(N), pow5(N);
	rep(i,0,N){
		pow10[i] = modint(10).pow(A[i]);
		pow9[i] = modint(9).pow(A[i]);
		pow7[i] = modint(7).pow(A[i]);
		pow5[i] = modint(5).pow(A[i]);
	}

	modint q = modint(Q);

	int ans = 0;
	rep(i,0,N) rep(j,i+1,N) rep(k,j+1,N) rep(l,k+1,N){
		modint a = pow10[i], b = pow9[j], c = pow7[k], d = pow5[l];
		if(a+b+c+d==q) ans++;
	}
	cout << ans << endl;
}
0