QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#461050#8486. CasinoLynkcat#WA 12ms19340kbC++141.4kb2024-07-02 15:33:202024-07-02 15:33:22

Judging History

This is the latest submission verdict.

  • [2024-07-02 15:33:22]
  • Judged
  • Verdict: WA
  • Time: 12ms
  • Memory: 19340kb
  • [2024-07-02 15:33:20]
  • Submitted

answer

#include<bits/stdc++.h>
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
#define int ll
// #define N 
using namespace std;
const int N=1000005;
int fac[N],inv[N];
inline int quickPower(int x,int y)
{
    int res=1;
    while (y)
    {
        if (y&1)res=res*x%mod;
        x=x*x%mod;
        y>>=1;
    }
    return res;
}
inline int C(int x,int y)
{
    if (x<y||y<0) return 0;
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
void BellaKira()
{
    fac[0]=1;
    for (int i=1;i<N;i++) fac[i]=fac[i-1]*i%mod;
    inv[N-1]=quickPower(fac[N-1],mod-2);
    for (int i=N-1;i>=1;i--) inv[i-1]=inv[i]*i%mod;
    int n;
    cin>>n;
    poly cnt(3,0);
    int ans=0;
    for (int i=1;i<=n;i++)
    {
        int x;
        cin>>x;
        cnt[x%3]++;
    }
    // cout<<cnt[1]<<" "<<cnt[2]<<" "<<cnt[0]<<endl;
    if (cnt[1]==cnt[2]+1||cnt[1]==cnt[2]+2)
    {
        ans=(ans+fac[cnt[1]]*fac[cnt[2]]%mod*C(n-1,cnt[0])%mod*fac[cnt[0]]%mod)%mod;
    }
    if (cnt[2]==cnt[1]+1||cnt[2]==cnt[1]+2)
    {
        ans=(ans+fac[cnt[1]]*fac[cnt[2]]%mod*C(n-1,cnt[0])%mod*fac[cnt[0]]%mod)%mod;
    }
    cout<<ans<<'\n';

}
signed main()
{
	IOS;
	cin.tie(0);
	int T=1;
	while (T--)
	{
		BellaKira();
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 12ms
memory: 19040kb

input:

3
100 21 892

output:

4

result:

ok 1 number(s): "4"

Test #2:

score: 0
Accepted
time: 12ms
memory: 19152kb

input:

4
11 19 30 32

output:

6

result:

ok 1 number(s): "6"

Test #3:

score: 0
Accepted
time: 8ms
memory: 19320kb

input:

3
4 298 28

output:

0

result:

ok 1 number(s): "0"

Test #4:

score: 0
Accepted
time: 6ms
memory: 19092kb

input:

5
24 27 38 46 94

output:

24

result:

ok 1 number(s): "24"

Test #5:

score: 0
Accepted
time: 12ms
memory: 19084kb

input:

5
72 84 11 51 21

output:

24

result:

ok 1 number(s): "24"

Test #6:

score: 0
Accepted
time: 12ms
memory: 19084kb

input:

5
84 51 12 6 69

output:

0

result:

ok 1 number(s): "0"

Test #7:

score: 0
Accepted
time: 8ms
memory: 19340kb

input:

5
30 66 27 36 60

output:

0

result:

ok 1 number(s): "0"

Test #8:

score: 0
Accepted
time: 8ms
memory: 19092kb

input:

10
98 39 37 19 45 73 83 42 73 3

output:

145152

result:

ok 1 number(s): "145152"

Test #9:

score: 0
Accepted
time: 8ms
memory: 19088kb

input:

10
89 34 37 93 47 12 56 26 3 51

output:

145152

result:

ok 1 number(s): "145152"

Test #10:

score: 0
Accepted
time: 12ms
memory: 19152kb

input:

10
73900926 31166686 581758479 266084782 136544545 864189216 334829736 346199618 111407115 84881126

output:

181440

result:

ok 1 number(s): "181440"

Test #11:

score: 0
Accepted
time: 3ms
memory: 19092kb

input:

10
374350674 408667992 305815278 141080955 705187668 53250180 908378583 123881433 725492762 607387956

output:

362880

result:

ok 1 number(s): "362880"

Test #12:

score: -100
Wrong Answer
time: 8ms
memory: 19156kb

input:

1000
24551 8084 73369 96016 90782 37319 35797 64970 52459 16561 61141 54762 81069 80237 48601 10843 1202 65279 4195 55258 89827 47014 78376 60803 51120 5914 48347 55895 88511 79208 49307 94324 26969 13367 92230 59021 13418 75515 19883 66005 49541 35616 49829 78359 709 63677 77152 45916 68528 54254 7...

output:

902228015

result:

wrong answer 1st numbers differ - expected: '856284522', found: '902228015'