Submission #36978760
Source Code Expand
// Author: Ruhan Habib (ruhanhabib39@gmail.com)
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <cassert>
using namespace std;
const long long MOD = 998244353LL;
const int MAXN = 2e5;
long long modpow (long long x, long long p) {
long long res = 1;
while (p > 0LL) {
if (p & 1LL) res = res * x % MOD;
p >>= 1LL;
x = x * x % MOD;
}
return res;
}
long long modinv (long long x) {
return modpow(x, MOD - 2);
}
long long dp[MAXN + 10];
void calc_dp (long long p) {
long long r = p * modinv(100) % MOD;
long long s = (1 + MOD - r) % MOD;
dp[0] = 0;
dp[1] = 1;
for (int i = 2; i <= MAXN; i++) {
dp[i] = (1 + r * dp[i-2] + s * dp[i-1]) % MOD;
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n, p; cin >> n >> p;
calc_dp(p);
cout << dp[n] << "\n";
}
Submission Info
| Submission Time | |
|---|---|
| Task | E - Critical Hit |
| User | ruhanhabib39 |
| Language | C++ (GCC 9.2.1) |
| Score | 500 |
| Code Size | 961 Byte |
| Status | AC |
| Exec Time | 9 ms |
| Memory | 5188 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 500 / 500 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 9 ms | 5128 KiB |
| example_01.txt | AC | 4 ms | 5064 KiB |
| example_02.txt | AC | 3 ms | 5124 KiB |
| hand_00.txt | AC | 4 ms | 5184 KiB |
| hand_01.txt | AC | 4 ms | 5064 KiB |
| hand_02.txt | AC | 5 ms | 5068 KiB |
| hand_03.txt | AC | 5 ms | 5120 KiB |
| hand_04.txt | AC | 4 ms | 5128 KiB |
| hand_05.txt | AC | 4 ms | 5068 KiB |
| hand_06.txt | AC | 4 ms | 5156 KiB |
| hand_07.txt | AC | 4 ms | 5008 KiB |
| hand_08.txt | AC | 7 ms | 5060 KiB |
| hand_09.txt | AC | 5 ms | 5068 KiB |
| hand_10.txt | AC | 4 ms | 5092 KiB |
| hand_11.txt | AC | 7 ms | 5124 KiB |
| hand_12.txt | AC | 5 ms | 5000 KiB |
| hand_13.txt | AC | 6 ms | 5152 KiB |
| random_00.txt | AC | 7 ms | 5156 KiB |
| random_01.txt | AC | 5 ms | 5056 KiB |
| random_02.txt | AC | 4 ms | 5060 KiB |
| random_03.txt | AC | 4 ms | 5068 KiB |
| random_04.txt | AC | 4 ms | 5128 KiB |
| random_05.txt | AC | 4 ms | 5048 KiB |
| random_06.txt | AC | 4 ms | 5152 KiB |
| random_07.txt | AC | 5 ms | 5140 KiB |
| random_08.txt | AC | 3 ms | 5124 KiB |
| random_09.txt | AC | 6 ms | 5124 KiB |
| random_10.txt | AC | 3 ms | 5188 KiB |
| random_11.txt | AC | 4 ms | 5120 KiB |
| random_12.txt | AC | 4 ms | 5156 KiB |
| random_13.txt | AC | 4 ms | 4996 KiB |
| random_14.txt | AC | 4 ms | 5152 KiB |
| random_15.txt | AC | 4 ms | 5012 KiB |
| random_16.txt | AC | 6 ms | 5156 KiB |
| random_17.txt | AC | 3 ms | 5056 KiB |
| random_18.txt | AC | 5 ms | 5120 KiB |
| random_19.txt | AC | 5 ms | 5124 KiB |
| random_20.txt | AC | 5 ms | 5116 KiB |
| random_21.txt | AC | 8 ms | 5068 KiB |