結果
問題 | No.435 占い(Extra) |
ユーザー |
![]() |
提出日時 | 2018-05-20 20:30:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 722 bytes |
コンパイル時間 | 351 ms |
コンパイル使用メモリ | 33,152 KB |
実行使用メモリ | 22,800 KB |
最終ジャッジ日時 | 2024-10-08 12:23:50 |
合計ジャッジ時間 | 6,144 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 6 WA * 26 |
ソースコード
#include <cstdio>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, ret = 0, f = 0;for (int i = 0; i < n; i++) {if (cur != 0) f = 1;ret = (ret + (ord == 0 ? cur % 10 : (ord == 1 ? cur % 10 % 3 * 3 : 0))) % 9;cur = ((cur ^ a) + b) % m;x = i + 1;while (x % 3 == 0) x /= 3, ord--;x = n - i - 1;while (x != 0 && x % 3 == 0) x /= 3, ord++;}printf("%d\n", ret + (ret == 0 && f == 1 ? 9 : 0));}return 0;}