SOLUTION INFO
C++ · main.cpp
- 작성자
- tony9402
- 공동 작성자
- 없음
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll S;
bool chk(ll n){ return n*(n+1)/2 > S; }
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> S;
ll l = 1, r = 93000; // sqrt(4294967295 * 2)
while(l <= r){
ll mid = (l + r) / 2;
if(chk(mid))r = mid - 1;
else l = mid + 1;
}
cout << r;
}
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 size = rd.nextLong();
long count = 1, sum = 0;
while(size >= sum) {
sum += count;
count++;
}
System.out.print(count - 2);
}
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
풀이 설명
등록된 풀이 설명이 없습니다.