11package c280 ;
22
3+ import java .nio .charset .StandardCharsets ;
4+ import java .util .Scanner ;
5+
36public class Abc280_e {
47 private static final int MOD = 998244353 ;
58
69 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 );
924 }
1025
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 ;
1331 }
1432
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 ;
2340 }
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 ;
2546 }
2647}
2748/*
2849E - Critical Hit
2950https://atcoder.jp/contests/abc280/tasks/abc280_e
51+
52+ exgcd 求逆元
3053 */
0 commit comments