結果
問題 | No.381 名声値を稼ごう Extra |
ユーザー |
![]() |
提出日時 | 2025-06-12 19:52:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 891 bytes |
コンパイル時間 | 183 ms |
コンパイル使用メモリ | 82,064 KB |
実行使用メモリ | 339,240 KB |
最終ジャッジ日時 | 2025-06-12 19:53:46 |
合計ジャッジ時間 | 9,698 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 1 TLE * 1 |
ソースコード
def divide_by_two(n_str): if n_str == '0': return '0' carry = 0 result = [] for c in n_str: current = carry * 10 + int(c) quotient = current // 2 remainder = current % 2 carry = remainder result.append(str(quotient)) # Remove leading zeros while len(result) > 1 and result[0] == '0': result.pop(0) return ''.join(result) def decimal_to_binary(n_str): if n_str == '0': return '0' binary = '' while n_str != '0': mod = int(n_str[-1]) % 2 binary = str(mod) + binary n_str = divide_by_two(n_str) return binary def count_set_bits(n_str): binary_str = decimal_to_binary(n_str) return binary_str.count('1') def main(): MOD = 1004535809 N = input().strip() count = count_set_bits(N) print(count % MOD) if __name__ == "__main__": main()