Created
December 30, 2016 01:00
-
-
Save johirbuet/443ac81fbe8a1e43b65d13f094001f23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class UVA573 { | |
public static void main(String[] args) { | |
Scanner sc=new Scanner(System.in); | |
while(true) | |
{ | |
double H = sc.nextDouble(); | |
double U = sc.nextDouble(); | |
double D = sc.nextDouble(); | |
double F = sc.nextDouble(); | |
if(H == 0 && U == 0 && D == 0 && F == 0) break; | |
double height = 0; | |
double speedUp = (U * F)/100; | |
int sum = 0; | |
boolean success = true; | |
while(true) { | |
sum++; | |
height = height + U; | |
if(height > H) break; | |
height = height - D; | |
if(height < 0.0) { | |
success = false; | |
break; | |
} | |
if(U - speedUp > 0.0) { | |
U = U - speedUp; | |
} else { | |
U = 0; | |
} | |
} | |
if(success) System.out.println("success on day " + sum); | |
else System.out.println("failure on day " + sum); | |
} | |
sc.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment