Skip to content

Commit

Permalink
pre-release v2023.03.15
Browse files Browse the repository at this point in the history
  • Loading branch information
gdut-yy committed Mar 15, 2023
1 parent c959639 commit 9ddbf59
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 565 deletions.
49 changes: 36 additions & 13 deletions atcoder-beginner/src/main/java/c280/Abc280_e.java
Original file line number Diff line number Diff line change
@@ -1,30 +1,53 @@
package c280;

import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Abc280_e {
private static final int MOD = 998244353;

public static void main(String[] args) {
// 281/100 (mod 998244353) = 229596204
System.out.println(281 * inv(100, MOD) % MOD);
Scanner scanner = new Scanner(System.in, StandardCharsets.UTF_8);
int n = scanner.nextInt();
int p = scanner.nextInt();
System.out.println(solve(n, p));
}

private static String solve(int n, int p) {
long inv = inv(100, MOD);
long x = 1, ans = 1;
for (int i = 0; i < n - 1; i++) {
x = (1 - x * p % MOD * inv % MOD + MOD) % MOD;
ans = (ans + x) % MOD;
}
return String.valueOf(ans);
}

private static long inv(long a, long mod) {
return quickPow(a, mod - 2, mod);
static long inv(long a, long b) {
x = 0;
y = 0;
exgcd(a, b);
return (x + b) % b;
}

private static long quickPow(long a, long b, long mod) {
long res = 1L;
while (b > 0) {
if ((b & 1) == 1) {
res = res * a % mod;
}
a = a * a % mod;
b >>= 1;
static long x, y;

static long exgcd(long a, long b) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
return res;
long d = exgcd(b, a % b);
long tmp = x;
x = y;
y = tmp - a / b * y;
return d;
}
}
/*
E - Critical Hit
https://atcoder.jp/contests/abc280/tasks/abc280_e
exgcd 求逆元
*/
33 changes: 33 additions & 0 deletions atcoder-beginner/src/test/java/c280/Abc280eTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package c280;

import base.AbstractOjTests;
import org.junit.jupiter.api.Test;

import java.io.IOException;

public class Abc280eTests extends AbstractOjTests {
public Abc280eTests() {
super("/c280/E/");
}

@Test
public void example1() throws IOException {
super.doSetSystemInOut(INPUT1);
Abc280_e.main(null);
super.doAssertion(OUTPUT1);
}

@Test
public void example2() throws IOException {
super.doSetSystemInOut(INPUT2);
Abc280_e.main(null);
super.doAssertion(OUTPUT2);
}

@Test
public void example3() throws IOException {
super.doSetSystemInOut(INPUT3);
Abc280_e.main(null);
super.doAssertion(OUTPUT3);
}
}
1 change: 1 addition & 0 deletions atcoder-beginner/src/test/resources/c280/E/input1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3 10
1 change: 1 addition & 0 deletions atcoder-beginner/src/test/resources/c280/E/input2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 100
1 change: 1 addition & 0 deletions atcoder-beginner/src/test/resources/c280/E/input3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
280 59
1 change: 1 addition & 0 deletions atcoder-beginner/src/test/resources/c280/E/output1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
229596204
1 change: 1 addition & 0 deletions atcoder-beginner/src/test/resources/c280/E/output2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3
1 change: 1 addition & 0 deletions atcoder-beginner/src/test/resources/c280/E/output3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
567484387
60 changes: 0 additions & 60 deletions codeforces-div1/src/main/java/p425/CF425C.java

This file was deleted.

54 changes: 0 additions & 54 deletions codeforces-div3/src/main/java/p1579/CF1579G.java

This file was deleted.

128 changes: 0 additions & 128 deletions codeforces-div3/src/main/java/p1650/CF1650E.java

This file was deleted.

5 changes: 4 additions & 1 deletion leetcode-05/src/main/java/Solution484.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ public int[] findPermutation(String s) {
1 <= s.length <= 10^5
s[i] 只会包含字符 'D' 和 'I'。
贪心,数组翻转
贪心,数组翻转。
时间复杂度 O(n)
相似题目: 2375. 根据模式串构造最小数字
https://leetcode.cn/problems/construct-smallest-number-from-di-string/
*/
Loading

0 comments on commit 9ddbf59

Please sign in to comment.