結果

問題 No.1895 Mod 2
ユーザー Shirotsume
提出日時 2022-01-17 10:33:58
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 34 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 4,277 ms
コンパイル使用メモリ 251,424 KB
最終ジャッジ日時 2025-01-27 12:50:53
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; i++)
ll check(ll x){
    if(x == 0) return 0;
    ll ok = 0;
    ll ng = 1000000000 + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(mid * mid <= x) ok = mid;
        else ng = mid;
    }
    ll ret = ok;
    ok = 0;
    ng = 1000000000 + 1;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(2 * mid * mid <= x) ok = mid;
        else ng = mid;
    }
    ret += ok;
    return ret;
    

}
int main(void)
{
    ll t;
    cin >> t;
    while(t--){
        ll l, r;
        cin >> l >> r;
        ll ans = check(r) - check(l - 1);
        cout << ans % 2 << endl;
    }
    return 0;
}
0