結果

問題 No.1895 Mod 2
ユーザー hourenhouren
提出日時 2022-04-08 22:26:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 738 bytes
コンパイル時間 1,515 ms
コンパイル使用メモリ 164,356 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 00:54:38
合計ジャッジ時間 2,336 ms
ジャッジサーバーID
(参考情報)
judge12 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 8 ms
4,380 KB
testcase_02 AC 8 ms
4,376 KB
testcase_03 AC 7 ms
4,380 KB
testcase_04 AC 8 ms
4,380 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 9 ms
4,376 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 7 ms
4,380 KB
testcase_11 AC 8 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
ll cal(ll x){
    ll ok = 0, ng = 32000000;
    while(ng-ok>1){
        ll md = (ng+ok)/2;
        if(md*md<=x) ok = md;
        else ng = md;
    }
    return ok;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    cin >> t;
    rep(houren,t){
        ll l,r;
        cin >> l >> r;
        l--;
        cout << (cal(r)+cal(r/2)-cal(l)-cal(l/2))%2 << '\n';
    }
    return 0;
}
0