結果

問題 No.2709 1975 Powers
ユーザー startcppstartcpp
提出日時 2024-03-31 13:33:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 802 ms
コンパイル使用メモリ 83,672 KB
実行使用メモリ 160,456 KB
最終ジャッジ日時 2024-03-31 13:33:48
合計ジャッジ時間 19,707 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 360 ms
160,456 KB
testcase_01 AC 354 ms
160,456 KB
testcase_02 AC 391 ms
160,456 KB
testcase_03 AC 709 ms
160,456 KB
testcase_04 AC 971 ms
160,456 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 364 ms
160,456 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 361 ms
160,456 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 416 ms
160,456 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1,069 ms
160,456 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 1,046 ms
160,456 KB
testcase_26 AC 1,045 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];
	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