結果
| 問題 | No.435 占い(Extra) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-19 04:02:00 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 899 bytes |
| 記録 | |
| コンパイル時間 | 1,175 ms |
| コンパイル使用メモリ | 170,804 KB |
| 実行使用メモリ | 9,936 KB |
| 最終ジャッジ日時 | 2026-10-19 04:02:07 |
| 合計ジャッジ時間 | 5,750 ms |
|
ジャッジサーバーID (参考情報) |
judge6_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 7 WA * 25 |
ソースコード
#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;
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 *= 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(); }
}