結果

問題 No.435 占い(Extra)
ユーザー square1001square1001
提出日時 2018-05-20 20:34:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 817 bytes
コンパイル時間 205 ms
コンパイル使用メモリ 34,176 KB
実行使用メモリ 23,552 KB
最終ジャッジ日時 2024-04-17 02:57:37
合計ジャッジ時間 6,188 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
23,424 KB
testcase_01 AC 73 ms
23,296 KB
testcase_02 AC 75 ms
23,296 KB
testcase_03 AC 72 ms
23,168 KB
testcase_04 AC 71 ms
23,168 KB
testcase_05 AC 72 ms
23,424 KB
testcase_06 WA -
testcase_07 AC 73 ms
23,296 KB
testcase_08 AC 73 ms
23,296 KB
testcase_09 AC 73 ms
23,296 KB
testcase_10 AC 76 ms
23,168 KB
testcase_11 AC 75 ms
23,296 KB
testcase_12 AC 85 ms
23,296 KB
testcase_13 AC 85 ms
23,424 KB
testcase_14 AC 86 ms
23,168 KB
testcase_15 AC 86 ms
23,424 KB
testcase_16 AC 91 ms
23,168 KB
testcase_17 AC 138 ms
23,424 KB
testcase_18 AC 85 ms
23,168 KB
testcase_19 AC 82 ms
23,296 KB
testcase_20 AC 184 ms
23,424 KB
testcase_21 AC 189 ms
23,168 KB
testcase_22 AC 191 ms
23,424 KB
testcase_23 AC 191 ms
23,424 KB
testcase_24 WA -
testcase_25 AC 243 ms
23,296 KB
testcase_26 AC 194 ms
23,168 KB
testcase_27 AC 193 ms
23,424 KB
testcase_28 AC 72 ms
23,424 KB
testcase_29 AC 193 ms
23,296 KB
testcase_30 WA -
testcase_31 AC 168 ms
23,296 KB
testcase_32 AC 177 ms
23,424 KB
testcase_33 AC 195 ms
23,296 KB
testcase_34 WA -
testcase_35 AC 191 ms
23,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#pragma warning(disable : 4996)
const int inv[] = { 0, 1, 5, 0, 7, 2, 0, 4, 8 };
int q, n, x, a, b, m; short fact[10000009];
int main() {
	fact[0] = 1;
	for (int i = 1; i <= 10000000; ++i) {
		x = i;
		while (x % 3 == 0) x /= 3;
		fact[i] = fact[i - 1] * x % 9;
	}
	scanf("%d", &q);
	while (q--) {
		scanf("%d%d%d%d%d", &n, &x, &a, &b, &m);
		int cur = x, ord = 0, mul = 1, ret = 0, f = 0;
		for (int i = 0; i < n; i++) {
			if (cur != 0) f = 1;
			ret = (ret + cur % 10 * (ord == 0 ? mul : (ord == 1 ? mul % 3 * 3 : 0))) % 9;
			cur = ((cur ^ a) + b) % m;
			x = i + 1;
			while (x % 3 == 0) x /= 3, ord--;
			mul = mul * inv[x % 9] % 9;
			x = n - i - 1;
			while (x != 0 && x % 3 == 0) x /= 3, ord++;
			mul = mul * x % 9;
		}
		printf("%d\n", ret + (ret == 0 && f == 1 ? 9 : 0));
	}
	return 0;
}
0