Skip to content

Commit 8f0295b

Browse files
committed
Educational Codeforces Round 109 (Rated for Div. 2)
1 parent ce3a1b2 commit 8f0295b

File tree

1 file changed

+29
-0
lines changed
  • codeforces/Educational Codeforces Round 109 (Rated for Div. 2)/Potion Making

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
5+
public class PotionMaking {
6+
public static void main(String[] args) throws IOException {
7+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
8+
int t = Integer.parseInt(br.readLine());
9+
while (t-- != 0) {
10+
int k = Integer.parseInt(br.readLine());
11+
if(k==100){
12+
System.out.println("1");
13+
continue;
14+
}
15+
int w= 100-k;
16+
int gcd=gcd(w,k);
17+
int a1=w/gcd;
18+
int a2= k/gcd;
19+
System.out.println(a1+a2);
20+
}
21+
br.close();
22+
}
23+
24+
private static int gcd(int a, int b){
25+
if (a == 0)
26+
return b;
27+
return gcd(b%a, a);
28+
}
29+
}

0 commit comments

Comments
 (0)