結果

問題 No.1895 Mod 2
ユーザー ShirotsumeShirotsume
提出日時 2022-01-17 10:33:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 3,791 ms
コンパイル使用メモリ 261,204 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-06 00:45:52
合計ジャッジ時間 4,636 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 25 ms
5,376 KB
testcase_02 AC 26 ms
5,376 KB
testcase_03 AC 22 ms
5,376 KB
testcase_04 AC 24 ms
5,376 KB
testcase_05 AC 28 ms
5,376 KB
testcase_06 AC 28 ms
5,376 KB
testcase_07 AC 28 ms
5,376 KB
testcase_08 AC 25 ms
5,376 KB
testcase_09 AC 25 ms
5,376 KB
testcase_10 AC 21 ms
5,376 KB
testcase_11 AC 25 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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