2869번 - 달팽이는 올라가고 싶다
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int v = sc.nextInt();
if((v-b) % (a-b) == 0){
System.out.println((v-b) / (a-b));
}else{
System.out.println((int)Math.ceil((float)(v-b)/(a-b)));
}
https://help.acmicpc.net/quest...
또한 float는 부정확하니 double을 사용하세요
댓글을 작성하려면 로그인해야 합니다.
a3620123 2년 전
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int v = sc.nextInt();
if((v-b) % (a-b) == 0){
System.out.println((v-b) / (a-b));
}else{
System.out.println((int)Math.ceil((float)(v-b)/(a-b)));
}
}
}