結果

問題 No.2709 1975 Powers
ユーザー anago-pieanago-pie
提出日時 2024-04-09 15:32:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 685 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 2,620 ms
コンパイル使用メモリ 201,528 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-09 15:32:30
合計ジャッジ時間 11,517 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 6 ms
6,944 KB
testcase_03 AC 344 ms
6,940 KB
testcase_04 AC 570 ms
6,940 KB
testcase_05 AC 414 ms
6,940 KB
testcase_06 AC 120 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 110 ms
6,940 KB
testcase_09 AC 384 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 12 ms
6,944 KB
testcase_12 AC 30 ms
6,940 KB
testcase_13 AC 403 ms
6,944 KB
testcase_14 AC 56 ms
6,940 KB
testcase_15 AC 65 ms
6,944 KB
testcase_16 AC 305 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 38 ms
6,944 KB
testcase_19 AC 559 ms
6,940 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 107 ms
6,944 KB
testcase_22 AC 685 ms
6,944 KB
testcase_23 AC 678 ms
6,940 KB
testcase_24 AC 672 ms
6,944 KB
testcase_25 AC 674 ms
6,940 KB
testcase_26 AC 673 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define debug 0
#define YES cout << "Yes" << endl;
#define NO cout << "No" << endl;
using ll = long long;
using ld = long double;
const int mod = 998244353;
const int MOD = 1000000007;
const double pi = atan2(0, -1);
#include <time.h>
#include <chrono>

ll modpow(ll x, int y, int m) {
	if (y == 0) {
		return 1;
	}
	if (y % 2 == 0) {
		ll t = modpow(x, y / 2, m);
		return (t * t) % m;
	}
	else {
		return (modpow(x, y - 1, m) * x) % m;
	}
}

int main() {
	int N, P, Q;
	cin >> N >> P >> Q;
	vector<int> A(N);
	rep(i, N) {
		cin >> A[i];
	}

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

	vector<ll> mi(N), mj(N), mk(N), ml(N);
	rep(i, N) {
		mi[i] = modpow(10, A[i], P);
		mj[i] = modpow(9, A[i], P);
		mk[i] = modpow(7, A[i], P);
		ml[i] = modpow(5, A[i], P);
	}

	int ans = 0;

	rep(i, N) {
		for (int j = i + 1; j < N; j++) {
			for (int k = j + 1; k < N; k++) {
				for (int l = k + 1; l < N; l++) {
					if ((mi[i] + mj[j] + mk[k] + ml[l]) % P == Q) {
						ans++;
					}
				}
			}
		}
	}

	cout << ans << endl;
}
0