-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
131 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 求逆元 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
5 100 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
280 59 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
229596204 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
567484387 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.