結果

問題 No.3102 floor sqrt xor
ユーザー maksim
提出日時 2025-04-11 22:15:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 161,912 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-04-11 22:15:54
合計ジャッジ時間 2,863 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define int long long
const int p=998244353;
int po(int a,int b) {if(b==0) return 1; if(b==1) return a; if(b%2==0) {int u=po(a,b/2);return (u*1LL*u)%p;} else {int u=po(a,b-1);return (a*1LL*u)%p;}}
int inv(int x) {return po(x,p-2);}
mt19937 rnd;
#define app push_back
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define debug(...) [](auto...a){ ((cout << a << ' '), ...) << endl;}(#__VA_ARGS__, ":", __VA_ARGS__)
#define debugv(v) do {cout<< #v <<" : {"; for(int izxc=0;izxc<v.size();++izxc) {cout << v[izxc];if(izxc+1!=v.size()) cout << ","; }cout <<"}"<< endl;} while(0)
#else
#define debug(...)
#define debugv(v)
#endif
#define lob(a,x) lower_bound(all(a),x)
#define upb(a,x) upper_bound(all(a),x)
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t;cin>>t;
    while(t--)
    {
        int n;cin>>n;
        int o=sqrt(n);
        int ans=(-1);
        for(int u1=o-10;u1<=o+10;++u1)
        {
            if(u1>=0)
            {
                int u=(n^u1);
                if(u1*u1<=u && (u1+1)*(u1+1)>u)
                {
                    ans=u;
                    break;
                }
            }
        }
        cout<<ans<<'\n';
    }
    return 0;
}
0