File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
codeforces/Educational Codeforces Round 109 (Rated for Div. 2)/Potion Making Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments