結果
問題 |
No.3102 floor sqrt xor
|
ユーザー |
|
提出日時 | 2025-04-11 22:55:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 998 bytes |
コンパイル時間 | 2,210 ms |
コンパイル使用メモリ | 194,836 KB |
実行使用メモリ | 19,136 KB |
最終ジャッジ日時 | 2025-04-11 22:55:41 |
合計ジャッジ時間 | 8,172 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | TLE * 1 |
other | -- * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); auto Sqrt = [&](long long x) -> long long { if(x == 0) return 0; if(x <= 3) return 1; long long s = sqrt(x); if(s*s == x) return s; if((s-1)*(s-1) == x) return s-1; if((s+1)*(s+1) == x) return s+1; if(s*s >= x) return s-1; if((s+1)*(s+1) >= x) return s; return s+1; }; int T; cin >> T; while(T--){ long long N; cin >> N; long long answer = -1; for(int i=0; i<=100; i++) if((Sqrt(i)^i) == N){answer = i; break;} if(answer != -1){cout << answer << "\n"; continue;} long long sn = Sqrt(N); for(int i=0; i<=sn; i++){ long long x = N+i; if((Sqrt(x)^x) == N){answer = i; break;} x = N-i; if((Sqrt(x)^x) == N){answer = i; break;} } cout << answer << "\n"; } }