結果
| 問題 |
No.2113 Distance Sequence 1.5
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2022-10-28 23:01:14 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 887 bytes |
| コンパイル時間 | 169 ms |
| コンパイル使用メモリ | 29,568 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 02:14:18 |
| 合計ジャッジ時間 | 837 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <stdio.h>
long long power_mod (long long a, long long b, long long mod_num) {
long long ans = 1LL;
if (b > 0LL) {
ans = power_mod(a, b/2LL, mod_num);
ans = (ans * ans) % mod_num;
if (b%2LL == 1LL) {
ans = (ans * a) % mod_num;
}
}
return ans;
}
int main () {
long long n = 0LL;
long long m = 0LL;
long long k = 0LL;
int res = 0;
long long ans = 0LL;
long long mod_num = 998244353LL;
res = scanf("%lld", &n);
res = scanf("%lld", &m);
res = scanf("%lld", &k);
if (k >= m) {
printf("%lld\n", power_mod(m%mod_num, 2LL*n, mod_num));
return 0;
}
ans = power_mod(k%mod_num, 2LL*n, mod_num);
ans += mod_num-power_mod((k-1LL)%mod_num, 2LL*n, mod_num);
ans *= (m-k+1LL)%mod_num;
ans %= mod_num;
ans += power_mod((k-1LL)%mod_num, 2LL*n, mod_num);
printf("%lld\n", ans%mod_num);
return 0;
}
chro_96