-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.java
More file actions
77 lines (69 loc) · 1.91 KB
/
Copy pathMain.java
File metadata and controls
77 lines (69 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package tree;
import java.io.*;
import java.util.*;
public class Main{
private int n; //器官
private float k1;
private float k2;
private float k;
private float weight;
private String stopGrowing="1";
public Main(){}
public Main(int n, float k1, float k2, float k, float weight){
this.n = n;
this.k1 = k1;
this.k2 = k2;
this.k = k;
this.weight = weight;
}
private String grow(){
int day = 1;
while(weight <= k){
if((k1+k2) <= 1){
stopGrowing = "inf";
break;
}
weight *= (k1 + k2);
stopGrowing = day + "";
day++;
}
return stopGrowing;
}
public static void main(String[] args){
List<String> out = new ArrayList<String>();
String s;
int T = 0;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try{
s = br.readLine();
T = Integer.valueOf(s);
}catch(IOException e){
e.printStackTrace();
}
for(int i=1; i<=T; i++){
String[] baseInfoList;
String[] organWeightList;
float firstDayWeight = 0;
try{
s = br.readLine();
baseInfoList = s.split(" ");
s = br.readLine();
organWeightList = s.split(" ");
for(int j=0; j<organWeightList.length; j++){
firstDayWeight += Float.valueOf(organWeightList[i]);
}
Main cat = new Main(Integer.valueOf(baseInfoList[0]),
Float.valueOf(baseInfoList[1]),
Float.valueOf(baseInfoList[2]),
Float.valueOf(baseInfoList[3]),
firstDayWeight);
out.add(cat.grow());
}catch(IOException e){
e.printStackTrace();
}
}
for(int i=1; i<=T; i++){
System.out.println("Case #" + i + ":" + out.get(i-1));
}
}
}