QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#234026 | #7632. Balanced Arrays | Geospiza# | WA | 14ms | 19396kb | C++20 | 1001b | 2023-11-01 13:12:40 | 2023-11-01 13:12:41 |
Judging History
answer
//#pragma GCC optimize(3,"Ofast","inline")
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
#define mod 998244353
#define Ma 1000005
using namespace std;
ll mul[Ma],pre[Ma];
ll po(ll p,ll x=mod-2)
{
ll sum=1;
while (x)
{
if (x&1) sum=sum*p%mod;
p=p*p%mod;
x>>=1;
}
return sum;
}
void pri()
{
mul[0]=pre[0]=1;
for (ll i=1;i<Ma;i++)
mul[i]=mul[i-1]*i%mod;
pre[Ma-1]=po(mul[Ma-1]);
for (ll i=Ma-2;i>=0;i--)
pre[i]=pre[i+1]*(i+1)%mod;
return;
}
ll C(ll x,ll y)
{
if (x<0||y<0||x>y) return 0;
return mul[y]*pre[x]%mod*pre[y-x]%mod;
}
ll n,m;
void sol()
{
cin>>n>>m;
ll ans=C(m,n+m-1);
ans=ans*ans%mod;
printf("%lld\n",ans);
return;
}
typedef pair<ll,ll> pll;
int main(){
ios::sync_with_stdio(0); cin.tie(0);
pri();
int T=1;
//cin>>T;
while (T--)
sol();
return 0;
}
/*
*/
詳細信息
Test #1:
score: 100
Accepted
time: 5ms
memory: 19396kb
input:
2 2
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: -100
Wrong Answer
time: 14ms
memory: 19212kb
input:
500000 500000
output:
249284959
result:
wrong answer 1st numbers differ - expected: '984531374', found: '249284959'