結果
| 問題 | No.435 占い(Extra) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-19 04:08:39 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 959 bytes |
| 記録 | |
| コンパイル時間 | 3,484 ms |
| コンパイル使用メモリ | 167,720 KB |
| 実行使用メモリ | 9,800 KB |
| 最終ジャッジ日時 | 2026-10-19 04:08:49 |
| 合計ジャッジ時間 | 9,346 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 3 WA * 7 RE * 22 |
ソースコード
#include <iostream>
#include <vector>
void solve() {
using namespace std;
int n, x, a, b, m;
cin >> n >> x >> a >> b >> m;
int r = x, c = 1, e = 0, ans = 0;
constexpr int inv[] = {0, 1, 5, 0, 7, 2, 0, 4, 8};
for (int i = 0; i < n; i++) {
int s = r % 10;
if (e == 0) {
ans += s * c;
} else if (e == 1) {
ans += s * c * 3;
}
ans %= 9;
if (i == n - 1) { break; }
int k = n - i - 1;
while (k % 3 == 0) {
k /= 3;
e++;
}
c *= k;
k = i + 1;
while (k % 3 == 0) {
k /= 3;
e--;
}
c *= inv[k];
c %= 3;
r ^= a;
r += b;
r %= m;
}
if (ans == 0) { ans = 9; }
cout << ans << "\n";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
std::cin >> t;
while (t--) { solve(); }
}