Skip to content

Commit 9ddbf59

Browse files
committed
pre-release v2023.03.15
1 parent c959639 commit 9ddbf59

File tree

17 files changed

+131
-565
lines changed

17 files changed

+131
-565
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,53 @@
11
package c280;
22

3+
import java.nio.charset.StandardCharsets;
4+
import java.util.Scanner;
5+
36
public 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
/*
2849
E - Critical Hit
2950
https://atcoder.jp/contests/abc280/tasks/abc280_e
51+
52+
exgcd 求逆元
3053
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package c280;
2+
3+
import base.AbstractOjTests;
4+
import org.junit.jupiter.api.Test;
5+
6+
import java.io.IOException;
7+
8+
public class Abc280eTests extends AbstractOjTests {
9+
public Abc280eTests() {
10+
super("/c280/E/");
11+
}
12+
13+
@Test
14+
public void example1() throws IOException {
15+
super.doSetSystemInOut(INPUT1);
16+
Abc280_e.main(null);
17+
super.doAssertion(OUTPUT1);
18+
}
19+
20+
@Test
21+
public void example2() throws IOException {
22+
super.doSetSystemInOut(INPUT2);
23+
Abc280_e.main(null);
24+
super.doAssertion(OUTPUT2);
25+
}
26+
27+
@Test
28+
public void example3() throws IOException {
29+
super.doSetSystemInOut(INPUT3);
30+
Abc280_e.main(null);
31+
super.doAssertion(OUTPUT3);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3 10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
5 100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
280 59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
229596204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
567484387

codeforces-div1/src/main/java/p425/CF425C.java

-60
This file was deleted.

codeforces-div3/src/main/java/p1579/CF1579G.java

-54
This file was deleted.

codeforces-div3/src/main/java/p1650/CF1650E.java

-128
This file was deleted.

leetcode-05/src/main/java/Solution484.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ public int[] findPermutation(String s) {
3636
1 <= s.length <= 10^5
3737
s[i] 只会包含字符 'D' 和 'I'。
3838
39-
贪心,数组翻转
39+
贪心,数组翻转。
40+
时间复杂度 O(n)
41+
相似题目: 2375. 根据模式串构造最小数字
42+
https://leetcode.cn/problems/construct-smallest-number-from-di-string/
4043
*/

0 commit comments

Comments
 (0)