結果
| 問題 |
No.2420 Simple Problem
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-20 23:34:54 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 622 ms / 2,000 ms |
| コード長 | 1,045 bytes |
| コンパイル時間 | 797 ms |
| コンパイル使用メモリ | 99,928 KB |
| 最終ジャッジ日時 | 2025-02-16 11:56:11 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 33 |
ソースコード
#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<tuple>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=1e9+7;
int main(){
int N;
cin>>N;
vector<ll> ans;
for(int i=0;i<N;i++){
ll A,B;
cin>>A>>B;
ll ub=1LL<<30;//ubは必ず満たす
ll lb=0;
auto f=[&](ll x){
if((x*x-A-B)<=0) return false;
return (4*A*B/(x*x-A-B)) < (x*x-A-B);
};
int cnt=0;
while(ub-lb>1){
//if(cnt>30) break;
//cnt++;
ll mid=(ub+lb)/2;
//cout<<"mid="<<mid<<endl;
if(f(mid)){
//midは条件を満たす
ub=mid;
}else{
lb=mid;
}
}
ans.push_back(ub);
}
for(ll v:ans){
cout<<v<<endl;
}
}