結果

問題 No.2709 1975 Powers
ユーザー startcppstartcpp
提出日時 2024-03-31 13:34:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,046 ms / 2,000 ms
コード長 901 bytes
コンパイル時間 743 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 160,456 KB
最終ジャッジ日時 2024-03-31 13:34:42
合計ジャッジ時間 19,043 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
160,456 KB
testcase_01 AC 353 ms
160,456 KB
testcase_02 AC 390 ms
160,456 KB
testcase_03 AC 711 ms
160,456 KB
testcase_04 AC 983 ms
160,456 KB
testcase_05 AC 782 ms
160,456 KB
testcase_06 AC 487 ms
160,456 KB
testcase_07 AC 361 ms
160,456 KB
testcase_08 AC 480 ms
160,456 KB
testcase_09 AC 756 ms
160,456 KB
testcase_10 AC 361 ms
160,456 KB
testcase_11 AC 372 ms
160,456 KB
testcase_12 AC 391 ms
160,456 KB
testcase_13 AC 775 ms
160,456 KB
testcase_14 AC 419 ms
160,456 KB
testcase_15 AC 425 ms
160,456 KB
testcase_16 AC 694 ms
160,456 KB
testcase_17 AC 362 ms
160,456 KB
testcase_18 AC 400 ms
160,456 KB
testcase_19 AC 930 ms
160,456 KB
testcase_20 AC 363 ms
160,456 KB
testcase_21 AC 467 ms
160,456 KB
testcase_22 AC 1,046 ms
160,456 KB
testcase_23 AC 1,045 ms
160,456 KB
testcase_24 AC 1,046 ms
160,456 KB
testcase_25 AC 1,045 ms
160,456 KB
testcase_26 AC 1,046 ms
160,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, p, q;
int a[200];
int ps[11][2000001];

signed main() {
	int i, j, k, l;

	cin >> n >> p >> q;
	
	for (i = 1; i <= 10; i++) {
		ps[i][0] = 1;
		for (j = 1; j <= 2000000; j++) {
			ps[i][j] = ps[i][j - 1] * i;
			ps[i][j] %= p;
		}
	}

	rep(i, n) cin >> a[i];
	sort(a, a + n);
	
	int ans = 0;
	rep(i, n) {
		for (j = i + 1; j < n; j++) {
			for (k = j + 1; k < n; k++) {
				for (l = k + 1; l < n; l++) {
					int val = (ps[10][a[i]] + ps[9][a[j]] + ps[7][a[k]] + ps[5][a[l]]) % p;
					if (val == q) {
						ans++;
					}
				}
			}
		}
	}

	cout << ans << endl;
	return 0;
}
0