Skip to content

Instantly share code, notes, and snippets.

@johirbuet
Created December 30, 2016 01:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johirbuet/443ac81fbe8a1e43b65d13f094001f23 to your computer and use it in GitHub Desktop.
Save johirbuet/443ac81fbe8a1e43b65d13f094001f23 to your computer and use it in GitHub Desktop.
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