結果

問題 No.2709 1975 Powers
ユーザー naimonon77naimonon77
提出日時 2024-04-07 20:10:03
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 2,961 bytes
コンパイル時間 1,976 ms
コンパイル使用メモリ 160,324 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-07 20:10:10
合計ジャッジ時間 5,976 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 2 ms
6,548 KB
testcase_02 AC 3 ms
6,548 KB
testcase_03 AC 156 ms
6,548 KB
testcase_04 AC 259 ms
6,548 KB
testcase_05 AC 176 ms
6,548 KB
testcase_06 AC 56 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 50 ms
6,548 KB
testcase_09 AC 181 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 6 ms
6,548 KB
testcase_12 AC 15 ms
6,548 KB
testcase_13 AC 183 ms
6,548 KB
testcase_14 AC 26 ms
6,548 KB
testcase_15 AC 31 ms
6,548 KB
testcase_16 AC 139 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 19 ms
6,548 KB
testcase_19 AC 254 ms
6,548 KB
testcase_20 AC 3 ms
6,548 KB
testcase_21 AC 50 ms
6,548 KB
testcase_22 AC 304 ms
6,548 KB
testcase_23 AC 304 ms
6,548 KB
testcase_24 AC 306 ms
6,548 KB
testcase_25 AC 306 ms
6,548 KB
testcase_26 AC 305 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define NOMINMAX
#define TEST_MODE true

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#include <regex>

using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep2(i,a,n) for(int i=a;i<(int)(n);++i)
#define rrep(i,n) for(int i=(n)-1;i>=0;--i)
#define reu(i,n) for(int i=1;i<=(int)(n);++i)

#define chmax(a,b) (a=(a)<(b)?(b):(a))
#define chmin(a,b) (a=(a)>(b)?(b):(a))

using ll = long long;
#define all(a) begin(a),end(a)
#define int long long

#ifdef LOCAL_ENV
#define dump(x) cerr<<#x<<" : "<<(x)<< "   \t"
#define dumpl(x) dump(x)<<endl
#define cerr_endl cerr<<endl
ofstream ofstream1("out.txt");
#define cout ofstream1

#else
#define dump(x) 
#define dumpl(x)
#define cerr_endl 
#endif

#define abp(o,a,b) cout<<(((o)?a:b))<<endl
#define YEP(x) abp(x,"YES","NO")
#define Yep(x) abp(x,"Yes","No")

const int inf = (int)1 << 60;
ll mod_n = (int)1e9 + 7;

const int MAX = (int)2e6 + 5;
const int MAX2 = 2005;

template<typename T>void ce_vector(vector<T> a) {
#ifdef LOCAL_ENV
	rep(i, a.size() - 1) cerr << a[i] << " "; cerr << a[a.size() - 1] << endl;
#endif 
}

template<typename T>void ce_vector(vector<pair<T, T>> a) {
#ifdef LOCAL_ENV
	rep(i, a.size()) cerr << a[i].first << "," << a[i].second << " "; cerr << endl;
#endif 
}

template<typename T>void o_vector(vector<T> a) {
	if (a.size() == 0) { cout << endl; return; }
	rep(i, a.size() - 1) cout << a[i] << " "; cout << a[a.size() - 1] << endl;
}

template<typename T>void o_vector(vector<pair<T, T>> a) { rep(i, a.size()) cout << a[i].first << "," << a[i].second << " "; cout << endl; }

ll pow_n(ll x, ll n) { ll r = 1; while (n > 0) { if (n & 1)r = (r * x) % mod_n; x = (x * x) % mod_n; n >>= 1; }return r; }


template<typename T>
vector<T> in_vec(int n) {
	vector<T> a(n);
	a.resize(n);
	rep(i, n) cin >> a[i];
	return a;
}

int div_ceil(int a, int b) { int r = a / b; if (a % b != 0)r++; return r; }

ll modular(ll x) {
	return ((x % mod_n + mod_n) % mod_n);
}

// end of template

struct Person {
	int pos, id;

	bool operator<(const Person& p) const {
		return pos < p.pos;
	}
};


struct Solver {
	void solve() {
		int N, P, Q; cin >> N >> P >> Q;
		mod_n = P;
		vector<int> a = in_vec<int>(N);
		sort(all(a));
		int cnt = 0;
		int pow_table[4] = { 10,9,7,5 };
		int p[4][205] = {};
		rep(i, 4) {
			rep(j, N) {
				p[i][j] = pow_n(pow_table[i], a[j]);
			}
		}
		rep(i, N) {
			rep2(j, i + 1, N) {
				rep2(k, j + 1, N) {
					rep2(l, k + 1, N) {
						//int tmp = pow_n(10, a[i]) + pow_n(9, a[j]) + pow_n(7, a[k]) + pow_n(5, a[l]);
						int tmp = p[0][i] + p[1][j] + p[2][k] + p[3][l];
						if (tmp % P == Q) cnt++;
					}
				}
			}
		}
		cout << cnt << endl;
	}


};















signed main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	cout << fixed << setprecision(2);

	Solver().solve();

#ifdef LOCAL_ENV
	cout << endl;
	cerr << endl << "\x1b[7m ↓ \x1b[0m" << endl;
	system("type out.txt");
#endif
	return 0;
}
0