当前位置: 代码迷 >> 综合 >> HDOJ 1302 The Snail
  详细解决方案

HDOJ 1302 The Snail

热度:37   发布时间:2023-10-21 19:34:30.0

HDACM1302

翻译题,注意点细节就ok

import java.util.Scanner;public class Main{
    public static void main(String[] args) {Scanner sc = new Scanner(System.in);while(sc.hasNext()){int h = sc.nextInt();int u = sc.nextInt();int d = sc.nextInt();int f = sc.nextInt();if (h==0) {break;}double sum = u;int day = 1;while (0<=sum && sum<=h) {sum -= d;sum += 1.0*u*(1.0-1.0*f*day/100);day++;if (sum-d<0) {sum -= d;break;}}if (sum>0) {System.out.println("success on day "+day);continue;}System.out.println("failure on day "+day);}}
}