feb 2015 problem 1 / 3 / 4

This commit is contained in:
Xevion
2020-02-21 05:45:14 -06:00
parent bc11562f49
commit ba32bcbd62
6 changed files with 178 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import static java.lang.System.out;
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
class Main {
public static void main(String[] args) throws IOException {
Scanner s = new Scanner(new File("climb.dat"));
for(int i = s.nextInt(); i > 0; i--) {
int up = s.nextInt();
int down = s.nextInt();
int hole = -1 * s.nextInt();
int attempts = 0;
int traverse = 0;
while(hole < 0) {
attempts++;
hole += up;
traverse += up;
if(hole < 0) {
hole -= down;
traverse += down;
}
}
out.println(String.format("%s %s", attempts, traverse));
}
}
}