結果

問題 No.3102 floor sqrt xor
コンテスト
ユーザー noya2
提出日時 2025-04-08 02:20:35
言語 C++23
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 537 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,956 ms
コンパイル使用メモリ 331,068 KB
実行使用メモリ 7,596 KB
最終ジャッジ日時 2026-07-08 13:37:14
合計ジャッジ時間 12,416 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 1
other AC * 16 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// USO (WA)

#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;
    for (ll k = n-width; k <= n+width; k++){
        if (0 <= k){
            if (isqrt(k) ^ k ^ n) continue;
            std::cout << k << '\n';
            return ;
        }
    }
    std::cout << -1 << '\n';
}

int main(){
    int t; std::cin >> t;
    while (t--){
        solve();
    }
}
0