QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#234026#7632. Balanced ArraysGeospiza#WA 14ms19396kbC++201001b2023-11-01 13:12:402023-11-01 13:12:41

Judging History

你现在查看的是最新测评结果

  • [2023-11-01 13:12:41]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:19396kb
  • [2023-11-01 13:12:40]
  • 提交

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'