Submission #50503511
Source Code Expand
#include <bits/stdc++.h>
#include <atcoder/modint>
const int MOD=998244353;
using mint = atcoder::static_modint<MOD>;
using namespace std;
typedef long long ll;
ll read(){ll r;scanf("%lld",&r);return r;}
// sum x^0+x^1+...+x^{pwr-1}
mint g(mint x,int pwr){ return (x==1)?pwr:((x.pow(pwr)-1)/(x-1)); }
int main(){
ll N=read();
ll M=read();
ll Q=read();
mint ans=0;
mint A=mint(N*(N+1)/2)*(2*M+1);
mint AQ1 = A.pow(Q-1); // A^{Q-1}
for(ll i=1;i<=N;i++) {
mint c = i*(N+1-i);
mint d = mint(N*(N+1)/2)*(2*M+1)-c*M;
assert(d != A);
ans += c*c/(d-A)*AQ1*(M*(M-1)/2)*(g(d/A,Q)-Q);
}
printf("%d\n",ans.val());
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | F - Do you like query problems? |
| User | cromarmot |
| Language | C++ 20 (gcc 12.2) |
| Score | 1000 |
| Code Size | 651 Byte |
| Status | AC |
| Exec Time | 80 ms |
| Memory | 3904 KiB |
Compile Error
Main.cpp: In function ‘ll read()’:
Main.cpp:7:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | ll read(){ll r;scanf("%lld",&r);return r;}
| ~~~~~^~~~~~~~~~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 1000 / 1000 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 0_000.txt, 0_001.txt, 0_002.txt |
| All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 0_000.txt | AC | 1 ms | 3780 KiB |
| 0_001.txt | AC | 1 ms | 3840 KiB |
| 0_002.txt | AC | 1 ms | 3644 KiB |
| 1_003.txt | AC | 1 ms | 3788 KiB |
| 1_004.txt | AC | 1 ms | 3896 KiB |
| 1_005.txt | AC | 1 ms | 3792 KiB |
| 1_006.txt | AC | 1 ms | 3836 KiB |
| 1_007.txt | AC | 1 ms | 3712 KiB |
| 1_008.txt | AC | 1 ms | 3768 KiB |
| 1_009.txt | AC | 1 ms | 3896 KiB |
| 1_010.txt | AC | 1 ms | 3572 KiB |
| 1_011.txt | AC | 1 ms | 3884 KiB |
| 1_012.txt | AC | 47 ms | 3848 KiB |
| 1_013.txt | AC | 75 ms | 3904 KiB |
| 1_014.txt | AC | 19 ms | 3672 KiB |
| 1_015.txt | AC | 4 ms | 3672 KiB |
| 1_016.txt | AC | 64 ms | 3900 KiB |
| 1_017.txt | AC | 40 ms | 3576 KiB |
| 1_018.txt | AC | 48 ms | 3632 KiB |
| 1_019.txt | AC | 38 ms | 3696 KiB |
| 1_020.txt | AC | 49 ms | 3664 KiB |
| 1_021.txt | AC | 70 ms | 3572 KiB |
| 1_022.txt | AC | 80 ms | 3660 KiB |
| 1_023.txt | AC | 79 ms | 3644 KiB |
| 1_024.txt | AC | 70 ms | 3648 KiB |
| 1_025.txt | AC | 78 ms | 3772 KiB |
| 1_026.txt | AC | 78 ms | 3656 KiB |
| 1_027.txt | AC | 70 ms | 3768 KiB |
| 1_028.txt | AC | 79 ms | 3844 KiB |
| 1_029.txt | AC | 78 ms | 3780 KiB |
| 1_030.txt | AC | 78 ms | 3904 KiB |
| 1_031.txt | AC | 78 ms | 3776 KiB |
| 1_032.txt | AC | 79 ms | 3660 KiB |
| 1_033.txt | AC | 79 ms | 3692 KiB |
| 1_034.txt | AC | 79 ms | 3836 KiB |
| 1_035.txt | AC | 79 ms | 3788 KiB |
| 1_036.txt | AC | 79 ms | 3716 KiB |
| 1_037.txt | AC | 79 ms | 3632 KiB |
| 1_038.txt | AC | 79 ms | 3888 KiB |
| 1_039.txt | AC | 79 ms | 3656 KiB |