結果
| 問題 |
No.3102 floor sqrt xor
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2025-04-08 02:25:33 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 186 ms / 2,000 ms |
| コード長 | 593 bytes |
| コンパイル時間 | 3,068 ms |
| コンパイル使用メモリ | 274,160 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-08 02:25:43 |
| 合計ジャッジ時間 | 8,491 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
// AYASHII
#include <bits/stdc++.h>
using ll = long long;
const ll width = 1001001;
ll isqrt(ll n){
if (n == 0) return 0;
ll x = std::sqrt(n) - 1;
return (x * (x + 2) < n ? x + 1 : x);
}
void solve(){
ll n; std::cin >> n;
ll sq = isqrt(n);
for (ll s = sq - width; s <= sq + width; s++){
if (s < 0) continue;
ll k = n ^ s;
if (s*s <= k && k < (s+1)*(s+1)){
std::cout << k << '\n';
return ;
}
}
std::cout << -1 << '\n';
}
int main(){
int t; std::cin >> t;
while (t--){
solve();
}
}
noya2