結果
問題 |
No.3102 floor sqrt xor
|
ユーザー |
![]() |
提出日時 | 2025-05-23 17:56:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 937 bytes |
コンパイル時間 | 1,740 ms |
コンパイル使用メモリ | 194,620 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-23 17:56:53 |
合計ジャッジ時間 | 3,749 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; typedef vector<VL> VVL; typedef long long LL; #define all(a) (a).begin(), (a).end() #define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl #define ALL(a) (a).begin(),(a).end() #define pb push_back LL f(LL n){ LL m=sqrt(n*1.0); m-=10; m=max(m,LL(0)); while(1){ if(m*m>n){m--;break;} m++; } //cout<<n<<' '<<m<<endl; return m; } void sol(){ LL n;cin>>n; if(n<=5000){ rep(i,max(2*n,LL(1000))){ int j=f(i); if(LL(i^j)==n){cout<<i<<endl;return;} } cout<<-1<<endl; return; } LL m=f(n)-5000; m=max(m,LL(0)); //cout<<'!'<<m<<endl; rep(kai,10000){ LL i=(m^n); if(f(i)==m){ cout<<i<<endl; return ; } m++; } cout<<-1<<endl; } int main() { int t;cin>>t; rep(i,t){sol();} }