結果
問題 | No.2709 1975 Powers |
ユーザー | kaityo_17 |
提出日時 | 2024-03-31 14:24:27 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 720 ms / 2,000 ms |
コード長 | 2,937 bytes |
コンパイル時間 | 4,006 ms |
コンパイル使用メモリ | 233,672 KB |
実行使用メモリ | 66,044 KB |
最終ジャッジ日時 | 2024-09-30 19:28:59 |
合計ジャッジ時間 | 13,178 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 83 ms
65,928 KB |
testcase_01 | AC | 84 ms
65,844 KB |
testcase_02 | AC | 87 ms
65,972 KB |
testcase_03 | AC | 400 ms
65,944 KB |
testcase_04 | AC | 617 ms
65,924 KB |
testcase_05 | AC | 457 ms
66,024 KB |
testcase_06 | AC | 192 ms
65,944 KB |
testcase_07 | AC | 83 ms
66,008 KB |
testcase_08 | AC | 200 ms
66,000 KB |
testcase_09 | AC | 441 ms
65,972 KB |
testcase_10 | AC | 85 ms
66,044 KB |
testcase_11 | AC | 93 ms
65,916 KB |
testcase_12 | AC | 106 ms
66,008 KB |
testcase_13 | AC | 481 ms
65,960 KB |
testcase_14 | AC | 151 ms
65,944 KB |
testcase_15 | AC | 144 ms
66,032 KB |
testcase_16 | AC | 371 ms
65,928 KB |
testcase_17 | AC | 85 ms
65,940 KB |
testcase_18 | AC | 124 ms
66,032 KB |
testcase_19 | AC | 620 ms
65,904 KB |
testcase_20 | AC | 86 ms
65,904 KB |
testcase_21 | AC | 183 ms
65,952 KB |
testcase_22 | AC | 708 ms
65,944 KB |
testcase_23 | AC | 718 ms
66,024 KB |
testcase_24 | AC | 712 ms
65,908 KB |
testcase_25 | AC | 706 ms
65,964 KB |
testcase_26 | AC | 720 ms
65,948 KB |
ソースコード
#include <bits/stdc++.h> #include <atcoder/all> #define rep(i,a,n) for(ll i = a; i < n; i++) #define yes (cout << "Yes" << endl) #define YES (cout << "YES" << endl) #define no (cout << "No" << endl) #define NO (cout << "NO" << endl) #define pb push_back #define pf push_front #define mp make_pair #define fi first #define se second #define all(a) (a).begin(),(a).end() using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vd = vector<double>; using vs = vector<string>; using vl = vector<long long>; using vvi = vector<vector<int>>; using Graph = vector<vector<int>>; const int mod = 998244353; const int MOD = 1000000007; const int dx[4] = {-1,0,1,0}; const int dy[4] = {0,1,0,-1}; ll chmin(ll a,ll b) { if(a < b) return a; else return b; } void O(vector<int> v) { rep(i,0,v.size()) { cout << v[i] << " "; } cout << endl; } void O(vector<string> v) { rep(i,0,v.size()) cout << v[i] << endl; cout << endl; } void O(int a) { cout << a << endl; } void O(ll a) { cout << a << endl; } void O(string s) { cout << s << endl; } struct unionfind { vector<int> data; unionfind(int size) : data(size, -1) { } bool unite(int x, int y) { x = root(x); y = root(y); if (x != y) { if (data[y] < data[x]) swap(x, y); data[x] += data[y]; data[y] = x; } return x != y; } bool same(int x, int y) { return root(x) == root(y); } int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); } int size(int x) { return -data[root(x)]; } }; ll gcd(ll a, ll b) { a = abs(a); b = abs(b); if (a < b)swap(a, b); while (b) { ll r = a % b; a = b; b = r; } return a; } //x,yがax+by=gcd(a,b)の解になる x,yが格納 ll extgcd(ll a, ll b, ll& x, ll& y) { ll d = a; if (b != 0) { d = extgcd(b, a % b, y, x); y -= (a / b) * x; } else { x = 1; y = 0; } return d; } ll pow(ll a,ll b) { ll ans = 1; rep(i,0,b) ans *= a; return ans; } int main() { ll n,p,q; cin >> n >> p >> q; ll a[n]; rep(i,0,n) { cin >> a[i]; } sort(a,a + n); ll ten[2000006],nine[2000006],seven[2000006],five[2000006]; ten[0] = 1; nine[0] = 1; seven[0] = 1; five[0] = 1; rep(i,1,2000006) { ten[i] = (ten[i - 1] * 10) % p; nine[i] = (nine[i - 1] * 9) % p; seven[i] = (seven[i - 1] * 7) % p; five[i] = (five[i - 1] * 5) % p; } //rep(i,0,p) cout << i << " " << ten[i] << " " << nine[i] << " " << seven[i] << " " << five[i] << endl; ll ans = 0; rep(i,0,n) rep(j,i + 1,n) rep(k,j + 1,n) rep(l,k + 1,n) { ll now = ten[a[i]] + nine[a[j]] + seven[a[k]] + five[a[l]]; now %= p; if(now == q) { ans++; //cout << a[i] << " " << a[j] << " " << a[k] << " " << a[l] << now << endl; } } cout << ans << endl; }