結果
| 問題 | No.2067 ±2^k operations |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-02 23:07:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,312 bytes |
| コンパイル時間 | 285 ms |
| コンパイル使用メモリ | 81,728 KB |
| 実行使用メモリ | 77,952 KB |
| 最終ジャッジ日時 | 2024-11-16 05:51:02 |
| 合計ジャッジ時間 | 6,245 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 8 WA * 15 |
ソースコード
"""
直近が
0
00...
1
11...
で遷移が変わるはず
11011
3なんだよな
"""
MOD = 998244353
bi = [1]
for _ in range(60):
bi.append(bi[-1] * 2 % MOD)
def solve(S):
eq = 0
ans = 0
dp = [0, 0, 0, 0]
eq = 1
cnt = 1
t = len(S) - 2
flg = True
for s in S[1:]:
ndp = [0] * 4
ndp[0] = dp[3]
ndp[1] = dp[0] + dp[1] + dp[2]
ndp[2] = dp[1]
ndp[3] = dp[0] + dp[2] + dp[3]
ans += (dp[0] + dp[1] + dp[2]) * bi[t]
ans %= MOD
if s == "1":
if cnt >= 2:
ndp[0] += 1
else:
ndp[1] += 1
ans += eq * bi[t]
cnt += 1
if cnt <= 2:
eq += 1
flg = False
elif flg:
cnt = 0
else:
if cnt == 1:
cnt = 0
else:
cnt = 1
flg = True
ndp[2] += 1
ans += bi[t]
ans %= MOD
t -= 1
dp = [d % MOD for d in ndp]
ans += eq
return ans % MOD
for _ in range(int(input())):
n = int(input())
ans = solve(bin(n)[2:])
print(ans)
exit()
print()
bef = 0
for i in range(1, 33):
ans = solve(bin(i)[2:])
print(bin(i)[2:], ans - bef, ans)
bef = ans