結果
| 問題 |
No.381 名声値を稼ごう Extra
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 18:08:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 781 bytes |
| コンパイル時間 | 188 ms |
| コンパイル使用メモリ | 82,876 KB |
| 実行使用メモリ | 71,408 KB |
| 最終ジャッジ日時 | 2025-06-12 18:10:40 |
| 合計ジャッジ時間 | 694 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 RE * 1 |
ソースコード
def main():
MOD = 1004535809
n_str = input().strip()
# Convert N to an integer
n = int(n_str)
# Convert to binary string
bin_str = bin(n)[2:]
L = len(bin_str)
# Compute cumulative sum of '1's from the start (most significant bit)
cumulative = [0] * (L + 1)
for i in range(L):
cumulative[i+1] = cumulative[i] + (1 if bin_str[i] == '1' else 0)
max_profit = 0
for k in range(1, L + 1):
pos = L - k
if pos < 0:
bit = 0
else:
bit = 1 if bin_str[pos] == '1' else 0
count = cumulative[L - k]
profit = bit + count
if profit > max_profit:
max_profit = profit
print(max_profit % MOD)
if __name__ == "__main__":
main()
gew1fw