結果
問題 | No.2709 1975 Powers |
ユーザー | Iroha_3856 |
提出日時 | 2024-03-31 13:51:23 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 279 ms / 2,000 ms |
コード長 | 4,709 bytes |
コンパイル時間 | 6,451 ms |
コンパイル使用メモリ | 331,900 KB |
実行使用メモリ | 34,564 KB |
最終ジャッジ日時 | 2024-09-30 18:30:27 |
合計ジャッジ時間 | 9,967 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
34,432 KB |
testcase_01 | AC | 41 ms
34,432 KB |
testcase_02 | AC | 44 ms
34,432 KB |
testcase_03 | AC | 166 ms
34,336 KB |
testcase_04 | AC | 244 ms
34,552 KB |
testcase_05 | AC | 180 ms
34,468 KB |
testcase_06 | AC | 83 ms
34,500 KB |
testcase_07 | AC | 42 ms
34,532 KB |
testcase_08 | AC | 80 ms
34,560 KB |
testcase_09 | AC | 177 ms
34,564 KB |
testcase_10 | AC | 42 ms
34,432 KB |
testcase_11 | AC | 46 ms
34,488 KB |
testcase_12 | AC | 52 ms
34,496 KB |
testcase_13 | AC | 184 ms
34,448 KB |
testcase_14 | AC | 60 ms
34,452 KB |
testcase_15 | AC | 65 ms
34,404 KB |
testcase_16 | AC | 148 ms
34,560 KB |
testcase_17 | AC | 43 ms
34,432 KB |
testcase_18 | AC | 54 ms
34,492 KB |
testcase_19 | AC | 239 ms
34,488 KB |
testcase_20 | AC | 43 ms
34,452 KB |
testcase_21 | AC | 79 ms
34,488 KB |
testcase_22 | AC | 274 ms
34,444 KB |
testcase_23 | AC | 274 ms
34,560 KB |
testcase_24 | AC | 273 ms
34,508 KB |
testcase_25 | AC | 279 ms
34,472 KB |
testcase_26 | AC | 276 ms
34,460 KB |
ソースコード
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; //AtCoder-Library #if __has_include(<atcoder/all>) #include<atcoder/all> using namespace atcoder; using mint = atcoder::modint998244353; #endif //PBDS-tree #if __has_include(<ext/pb_ds/assoc_container.hpp>) #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/tag_and_trait.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //tree.find_by_order(k) = tree[k] (0-indexed) //tree.order_of_key(k) = tree.lower_bound(k) - tree.begin() //Note: Can only be used for non-multiple sets. #endif #define vec vector #define ll long long #define ull unsigned long long #define vi vec<int> #define vll vec<ll> #define vb vec<bool> #define vvi vec<vi> #define vvll vec<vll> #define vvb vec<vb> #define vvvi vec<vvi> #define vvvll vec<vvll> #define vvvb vec<vvb> #define pii pair<int, int> #define pll pair<ll, ll> #define pli pair<ll, int> #define pq priority_queue template<class T> using spq = priority_queue<T, vector<T>, greater<T>>; #define eb emplace_back #define pb push_back #define spa " " #define all(x) (x).begin(), (x).end() #define rep(i, l, r) for (int i=(int)(l); i<(int)(r); i++) #define REP(i, l, r) for (int i=(int)(l); i<=(int)(r); i++) #define siz(x) (int)x.size() template<class T>bool chmax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, T b) { if (b<a) { a=b; return 1; } return 0; } //Slice(A, l, r) = A[l, r) template<class T> vector<T> Slice(vector<T> A, int l, int r) { assert(0 <= l && l < (int)A.size()); assert(0 <= r && r <= (int)A.size()); vector<T> ret; for (int i = l; i<r; i++) ret.push_back(A[i]); return ret; } //Slice(S, l, r) = S[l, r) string Slice(string s, int l, int r) { assert(0 <= l && l < (int)s.size()); assert(0 <= r && r <= (int)s.size()); string ret; for (int i = l; i<r; i++) ret += s[i]; return ret; } ll Ceil(ll x, ll y) { assert(y != 0); if ((x >= 0) == (y >= 0)) { return (abs(x) + abs(y)-1)/abs(y); } else { return -(abs(x)/abs(y)); } } ll Floor(ll x, ll y) { assert(y != 0); if ((x >= 0) == (y >= 0)) { return abs(x)/abs(y); } else { return -((abs(x) + abs(y)-1)/abs(y)); } } template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for(auto &x : v) { is >> x; } return is; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int)v.size(); i++) { if(i != (int)v.size() - 1) os << v[i] << " "; else os << v[i]; } return os; } template<class T> void print(T A, bool f = true) { cerr << A; if (f) cerr << endl; } template<class T, class U> void print(pair<T, U> A, bool f = true) { cerr << "{" << A.first << ", " << A.second << "}"; if (f) cerr << endl; } template<class T> void print(vector<T> A, bool f = true) { cerr << "{"; for (int i = 0; i<(int)A.size(); i++) { print(A[i], false); if (i+1 != (int)A.size()) cerr << ", "; } cerr << "}"; if (f) cerr << endl; } #define debug(x) cerr << #x << " = "; print(x) #define debug2(x) cerr << #x << " = "; print(x, false) struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); } } iosetup; struct Edge { int to; int cost; Edge(int to, int cost) : to(to), cost(cost) {} }; const int mod1 = 998244353; const int mod2 = 1000000007; const int inf = 1000010000; const ll INF = 1LL<<60; int main() { int N, P, Q; cin >> N >> P >> Q; vector<int> P10(2000006), P9(2000006), P7(2000006), P5(2000006); P10[0] = P9[0] = P7[0] = P5[0] = 1; rep(i, 1, 2000006) { P10[i] = (P10[i-1] * 10)%P; P7[i] = (P7[i-1] * 7)%P; P9[i] = (P9[i-1] * 9)%P; P5[i] = (P5[i-1] * 5)%P; } int ans = 0; vector<int> A(N); rep(i, 0, N) cin >> A[i]; sort(A.begin(), A.end()); rep(a, 0, N) rep(b, a+1, N) rep(c, b+1, N) rep(d, c+1, N) { int p = 0; p += P10[A[a]]; p%=P; p += P9[A[b]]; p%=P; p += P7[A[c]]; p%=P; p += P5[A[d]]; p%=P; if (p == Q) ans++; } cout << ans << endl; }