結果

問題 No.2420 Simple Problem
ユーザー にしろにしろ
提出日時 2024-01-14 18:56:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 5,212 bytes
コンパイル時間 6,820 ms
コンパイル使用メモリ 316,240 KB
実行使用メモリ 9,512 KB
最終ジャッジ日時 2024-01-14 18:57:07
合計ジャッジ時間 26,613 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,512 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using ld = long double;
using st = string;
using mint = atcoder::modint998244353;
using Mint = atcoder::modint1000000007;
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<ld>
#define vvd vector<vector<ld>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vp vector<pair<ll,ll>>
#define vvp vector<vector<pair<ll,ll>>>
#define vm vector<mint>
#define vvm vector<vector<mint>>
#define vM vector<Mint>
#define vvM vector<vector<Mint>>
#define chmax(n,v) n=n<v?v:n
#define chmin(n,v) n=n>v?v:n
#define all(n) begin(n),end(n)
#define nxp(a) next_permutation(all(a))
#define rev(n) reverse(all(n))
#define sor(n) stable_sort(all(n))
#define rep(i,n) for(ll i=0;i<(n);++i)
#define reprev(i,n) for(ll i=n-1;0<=i;--i)
#define rrep(i,a,n) for(ll i=a;i<(n);++i)
#define sz(n) n.size()
#define bit(n,shift) ((n&(1<<shift))!=0)
#define yn(x) cout << (x?"Yes":"No") << endl;
#define lb(a,n) lower_bound(a.begin(),a.end(),n)-a.begin()
#define ub(a,n) upper_bound(a.begin(),a.end(),n)-a.begin()
#define lb2(a,n) *lower_bound(a.begin(),a.end(),n)
#define ub2(a,n) *upper_bound(a.begin(),a.end(),n)
template <typename T> void input(T &a) { cin >> a; };
template <typename T1, typename... T2> void input(T1&a, T2 &...b) { cin >> a; input(b...); };
const ll inf = 1e18;

//std::setprecision(13); 出力桁を増やす
//2^29<10^9

ll di[8]={1,-1,0,0,1,1,-1,-1};
ll dj[8]={0,0,1,-1,1,-1,-1,1};
//ll da[4]={1,1,-1,-1};
//ll db[4]={1,-1,-1,1};
//ll na[4]={1,0,1,0};
//ll nb[4]={0,1,0,1};

template<typename T = ll>
vector<T> rd(size_t n) {
  vector<T> ts(n);
  for (size_t i = 0; i < n; i++) cin >> ts[i];
  return ts;
}

bool is_prime(ll N) {
    if (N == 1) return false;
    for (ll i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

int calc_digit(ll N){
    int res = 0;
    while(N>0){
        res++;
        N/=10;
    }
    return res;
}

ll factorial(ll n, ll mod = 1e18) {
    ll ans = 1;
    for(ll i = n; i >= 2; i--) ans = (ans * i) % mod;
    return ans;
}

void printl(vl v){
    ll vsz=v.size();
    for(ll i=0;i<vsz;i++){
        cout << v[i] << endl;
    }
}


void prints(vs v){
    ll vsz=v.size();
    for(ll i=0;i<vsz;i++){
        cout << v[i] << endl;
    }
}

ll round_up(ll x,ll y){
    return (x+y-1)/y;
}

bool in_out(ll x,ll y,ll h,ll w){
    return 0<=x and x<h and 0<=y and y<w;
}

struct UnionFind{

    vector<ll> par;
    vector<ll> size;
    
    UnionFind(ll n){
        par.resize(2*(n+1),-1);
        size.resize(2*(n+1),1);
    }

    ll root(ll x){
        if (par[x]==-1) return x;
        return par[x]=root(par[x]);
    }

    void unite(ll u,ll v){
        ll uu=root(u),vv=root(v);
        if(uu==vv){
            return;
        }
        if(size[uu]<size[vv]){
            par[uu]=vv;
            size[vv]+=size[uu];
        }else{
            par[vv]=uu;
            size[uu]+=size[vv];
        }
        return;
    }

    bool same(ll u,ll v){
        return root(u)==root(v);
    }

    ll out_size(ll n){
        return size[n];
    }

};

const int MAX = 510000;
mint fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    const int MOD = mint::mod();
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i;
        inv[i] = MOD - inv[MOD%i] * (MOD / i);
        finv[i] = finv[i - 1] * inv[i];
    }
}

// 二項係数計算
mint COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * finv[k] * finv[n - k];
}

vector<pair<ll, ll>> prime_factorize(ll N){
    vector<pair<ll, ll> > res;
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0;
        while (N % a == 0) {
            ex++;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

vl p_list(ll n){
    vl res;
    vb check(n+1);
    for(ll i=2;i<=n;i++){
        if(check[i]) continue;
        res.push_back(i);
        ll ii=i;
        while(ii<=n){
            check[ii]=true;
            ii+=i;
        }
    }
    return res;
}

ll sum_v(vl a){
    ll res=0;
    ll n=sz(a);
    rep(i,n) res+=a[i];
    return res;
}

vl cumulative_sum(vl a){
    ll s=sz(a);
    vl b(s+1,0);
    for(ll i=0;i<s;i++){
        b[i+1]=a[i]+b[i];
    }
    return b;
}

ll floor(ll x,ll m){
    ll r=(x%m+m)%m; //負の剰余を正の剰余に置き換える
    return (x-r)/m;
}

ll bubble_sort(vl& a,ll& n){
    ll res=0;
    rep(i,n-1){
        for(ll j=n-1;j>i;j--){
            if(a[j-1]>a[j]){
                swap(a[j-1],a[j]);
                res++;
            }
        }
    }
    return res;
}

ll bi_search(unsigned &a,unsigned &b){
    ll ng=2,ok=70000;
    while(abs(ok-ng)>1){
        ll mid=(ok+ng)/2;
        unsigned y=(mid*mid)-a-b;
        if(4*a*b<y*y&&mid*mid>a+b) ok=mid;
        else ng=mid;
    }
    return ok;
}

int main(){
    
    unsigned n,a,b;
    cin >> n;

    rep(i,n){
        cin >> a >> b;
        cout << bi_search(a,b) << endl;
    }

}
0