티스토리 뷰
[Code]
import java.util.*;
class Main {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
int S = scan.nextInt();
System.out.println(maxcnt(S));
}
public static int maxcnt(int S){
int max = 0;
int cnt = 0;
int i=1;
while(max <= S){
max += i;
i++;
cnt++;
}
cnt--;
return cnt;
}
}
[Error Message]
java.util.InputMismatchException
[Solution]
타입변경 : int -> long
[결론]
int는
-2147483648 ~ 2147483647
long은
-9223372036854775808 ~ 9223372036854775807
까지 표현할 수 있습니다.
'Error Case' 카테고리의 다른 글
[Spring Boot / Error] invalid source release: 11 (0) | 2022.02.24 |
---|---|
[Spring Boot / Error] JAVA_HOME is set to an invalid directory (0) | 2022.02.24 |
[Java] 배열 내용 출력하기 (0) | 2021.12.14 |