結果
| 問題 |
No.3276 Make Smaller Popcount
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-20 17:59:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 385 ms / 2,000 ms |
| コード長 | 732 bytes |
| コンパイル時間 | 319 ms |
| コンパイル使用メモリ | 82,800 KB |
| 実行使用メモリ | 90,072 KB |
| 最終ジャッジ日時 | 2025-09-20 18:00:10 |
| 合計ジャッジ時間 | 11,115 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
## https://yukicoder.me/problems/no/3276
def solve(N):
array = []
while N > 0:
array.append(N % 2)
N //= 2
p_count = sum(array)
if p_count == 1:
return -1
answer = 0
f = False
for i in range(len(array)):
x = 2 ** i
if array[i] == 1:
if not f:
answer += x
f = True
else:
return answer
else:
if f:
answer += x
def main():
T = int(input())
answers = []
for _ in range(T):
N = int(input())
ans = solve(N)
answers.append(ans)
for ans in answers:
print(ans)
if __name__ == "__main__":
main()