結果
問題 |
No.381 名声値を稼ごう Extra
|
ユーザー |
![]() |
提出日時 | 2025-06-12 12:54:04 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 781 bytes |
コンパイル時間 | 210 ms |
コンパイル使用メモリ | 82,416 KB |
実行使用メモリ | 72,048 KB |
最終ジャッジ日時 | 2025-06-12 12:57:47 |
合計ジャッジ時間 | 759 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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()