結果
| 問題 |
No.381 名声値を稼ごう Extra
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 19:54:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,102 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,220 KB |
| 実行使用メモリ | 335,764 KB |
| 最終ジャッジ日時 | 2025-06-12 19:55:18 |
| 合計ジャッジ時間 | 9,599 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 TLE * 1 |
ソースコード
def decimal_to_bin(s):
if s == '0':
return '0'
bin_str = ''
num = s
while num != '0':
quotient, rem = divide_by_two(num)
bin_str += str(rem)
num = quotient
bin_str = bin_str[::-1]
return bin_str
def divide_by_two(num_str):
rem = 0
quotient = []
for c in num_str:
digit = int(c)
current = rem * 10 + digit
rem = current % 2
quotient_digit = current // 2
quotient.append(str(quotient_digit))
# Remove leading zeros
while len(quotient) > 0 and quotient[0] == '0':
quotient.pop(0)
if not quotient:
quotient_str = '0'
else:
quotient_str = ''.join(quotient)
return quotient_str, rem
def count_set_bits(num_str):
if num_str == '0':
return 0
bin_str = decimal_to_bin(num_str)
return bin_str.count('1')
def main():
import sys
input = sys.stdin.read().strip()
n = input
if n == '0':
print(0)
return
max_extra = count_set_bits(n)
print(max_extra % 1004535809)
if __name__ == "__main__":
main()
gew1fw