結果
| 問題 | No.1162 Many Quotients hard | 
| ユーザー |  misora192 | 
| 提出日時 | 2020-08-14 09:33:01 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 994 bytes | 
| コンパイル時間 | 1,601 ms | 
| コンパイル使用メモリ | 170,520 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-10-10 11:32:52 | 
| 合計ジャッジ時間 | 3,096 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 25 WA * 17 | 
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll n;
bool cond(ll x){
	return x * x > n;
}
// condを満たす最小のxを求める(lower_bound)
// 全てのxが条件を満たさない場合はnを返す(nはとりえない値)
ll lower_bound_cond(){
	ll lb = -1, ub = n;
	while(ub - lb > 1){
		ll mid = (lb + ub) / 2;
		if(cond(mid)) ub = mid;   // Answer is in (lb, mid]
		else lb = mid;            // Answer is in (mid, ub]
	}
	// now lb + 1 = ub
	return ub;
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	if(n <= 10){
		set<ll> st;
		for(ll i = 1; i <= n; i++) st.insert(n / i);
		cout << st.size() << endl;
		exit(0);
	}
	ll x = lower_bound_cond();
	cout << x + n / x - 1 << endl;
}	
            
            
            
        