結果
| 問題 | No.1853 Many Operations |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-11-14 21:30:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 814 bytes |
| 記録 | |
| コンパイル時間 | 697 ms |
| コンパイル使用メモリ | 82,184 KB |
| 実行使用メモリ | 54,500 KB |
| 最終ジャッジ日時 | 2025-11-14 21:30:23 |
| 合計ジャッジ時間 | 2,563 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | AC * 3 WA * 23 |
ソースコード
MOD = 998244353
def main():
import sys
data = sys.stdin.read().split()
if not data:
return
N = int(data[0])
if N == 0:
print(0)
return
L_max = N.bit_length()
B_N = 0
for k in range(0, L_max):
power_k = 1 << k
power_k1 = 1 << (k + 1)
full_cycles = N // power_k1
count_full = full_cycles * power_k
remainder = N % power_k1
if remainder >= power_k:
count_rem = remainder - power_k + 1
else:
count_rem = 0
B_N += count_full + count_rem
term1 = (L_max - 1) * N
term2 = L_max + 1
term3 = 1 << L_max
S_N = term1 + term2 - term3 + B_N
S_N %= MOD
if S_N < 0:
S_N += MOD
print(S_N)
if __name__ == '__main__':
main()
vjudge1