SOLUTION INFO
C++ · main.cpp
- 작성자
- tony9402
- 공동 작성자
- 없음
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool chk(ll a, ll b) {
if(b % a == 0) return a >= b / a;
return a > b / a;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
ll N; cin >> N;
if(N == 0) {
cout << 0;
return 0;
}
ll L = 1, R = 1LL << 32;
while(L <= R) {
ll mid = L + (R - L) / 2;
if(chk(mid, N)) R = mid - 1;
else L = mid + 1;
}
cout << L;
return 0;
}
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.
SOLUTION INFO
Java · Main.java
- 작성자
- lms0806
- 공동 작성자
- 없음
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException{
FastReader rd = new FastReader();
long n = rd.nextLong(), num = (long)Math.sqrt(n);
System.out.print(num >= n ? num : num + 1);
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while(st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble() { return Double.parseDouble(next()); }
String nextLine() {
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
SOLUTION DESCRIPTION
풀이 설명
등록된 풀이 설명이 없습니다.