1
1
package c280 ;
2
2
3
+ import java .nio .charset .StandardCharsets ;
4
+ import java .util .Scanner ;
5
+
3
6
public class Abc280_e {
4
7
private static final int MOD = 998244353 ;
5
8
6
9
public static void main (String [] args ) {
7
- // 281/100 (mod 998244353) = 229596204
8
- System .out .println (281 * inv (100 , MOD ) % MOD );
10
+ Scanner scanner = new Scanner (System .in , StandardCharsets .UTF_8 );
11
+ int n = scanner .nextInt ();
12
+ int p = scanner .nextInt ();
13
+ System .out .println (solve (n , p ));
14
+ }
15
+
16
+ private static String solve (int n , int p ) {
17
+ long inv = inv (100 , MOD );
18
+ long x = 1 , ans = 1 ;
19
+ for (int i = 0 ; i < n - 1 ; i ++) {
20
+ x = (1 - x * p % MOD * inv % MOD + MOD ) % MOD ;
21
+ ans = (ans + x ) % MOD ;
22
+ }
23
+ return String .valueOf (ans );
9
24
}
10
25
11
- private static long inv (long a , long mod ) {
12
- return quickPow (a , mod - 2 , mod );
26
+ static long inv (long a , long b ) {
27
+ x = 0 ;
28
+ y = 0 ;
29
+ exgcd (a , b );
30
+ return (x + b ) % b ;
13
31
}
14
32
15
- private static long quickPow (long a , long b , long mod ) {
16
- long res = 1L ;
17
- while (b > 0 ) {
18
- if ((b & 1 ) == 1 ) {
19
- res = res * a % mod ;
20
- }
21
- a = a * a % mod ;
22
- b >>= 1 ;
33
+ static long x , y ;
34
+
35
+ static long exgcd (long a , long b ) {
36
+ if (b == 0 ) {
37
+ x = 1 ;
38
+ y = 0 ;
39
+ return a ;
23
40
}
24
- return res ;
41
+ long d = exgcd (b , a % b );
42
+ long tmp = x ;
43
+ x = y ;
44
+ y = tmp - a / b * y ;
45
+ return d ;
25
46
}
26
47
}
27
48
/*
28
49
E - Critical Hit
29
50
https://atcoder.jp/contests/abc280/tasks/abc280_e
51
+
52
+ exgcd 求逆元
30
53
*/
0 commit comments