結果
| 問題 | No.3102 floor sqrt xor |
| コンテスト | |
| ユーザー |
ゼット
|
| 提出日時 | 2025-04-11 22:02:09 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 72 ms / 2,000 ms |
| コード長 | 420 bytes |
| 記録 | |
| コンパイル時間 | 232 ms |
| コンパイル使用メモリ | 95,600 KB |
| 実行使用メモリ | 83,928 KB |
| 最終ジャッジ日時 | 2026-07-08 19:00:39 |
| 合計ジャッジ時間 | 4,396 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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)
ゼット