結果
| 問題 |
No.3102 floor sqrt xor
|
| コンテスト | |
| ユーザー |
ゼット
|
| 提出日時 | 2025-04-11 22:02:09 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 63 ms / 2,000 ms |
| コード長 | 420 bytes |
| コンパイル時間 | 638 ms |
| コンパイル使用メモリ | 82,584 KB |
| 実行使用メモリ | 73,828 KB |
| 最終ジャッジ日時 | 2025-04-11 22:02:13 |
| 合計ジャッジ時間 | 3,556 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
Q=int(input())
from math import isqrt
for _ in range(Q):
N=int(input())
ans=0
for k in range(59,-1,-1):
z=ans^(isqrt(ans))
if (z>>k)&1:
a=1
else:
a=0
if (N>>k)&1:
b=1
else:
b=0
if a!=b:
ans+=2**k
if ans^(isqrt(ans))==N:
print(ans)
elif (ans+1)^(isqrt(ans+1))==N:
print(ans+1)
elif (ans-1)^(isqrt(ans-1))==N:
print(ans+1)
else:
print(-1)
ゼット