QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#118526 | #6625. Binaria | zhouhuanyi | 0 | 2ms | 4596kb | C++11 | 1.2kb | 2023-07-03 16:55:45 | 2023-07-03 16:55:48 |
Judging History
answer
#include<iostream>
#include<cstdio>
#define N 100000
#define mod 1000003
using namespace std;
int read()
{
char c=0;
int sum=0;
while (c<'0'||c>'9') c=getchar();
while ('0'<=c&&c<='9') sum=sum*10+c-'0',c=getchar();
return sum;
}
int fast_pow(int a,int b)
{
int res=1,mul=a;
while (b)
{
if (b&1) res=1ll*res*mul%mod;
mul=1ll*mul*mul%mod,b>>=1;
}
return res;
}
int n,k,a[N+1],s[N+1],fac[N+1],invfac[N+1];
bool used[N+1],used2[N+1];
int C(int x,int y)
{
if (x<y) return 0;
return 1ll*fac[x]*invfac[y]%mod*invfac[x-y]%mod;
}
int main()
{
int cnt,cnt2=0;
fac[0]=1;
for (int i=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
invfac[N]=fast_pow(fac[N],mod-2);
for (int i=N-1;i>=0;--i) invfac[i]=1ll*invfac[i+1]*(i+1)%mod;
n=read(),k=read();
for (int i=1;i<=n-k+1;++i) a[i]=read(),s[i+k-1]=s[i-1]+a[i];
for (int i=0;i<=n-1;++i)
{
if (s[i]+1==s[i+1]&&i%k!=k-1) used[i%k]=1;
if (s[i]-1==s[i+1]&&i%k!=k-1) used2[i%k]=1;
}
cnt=a[1];
for (int i=0;i<=k-1;++i)
{
if (used2[i]) cnt--;
else if (!used[i]) cnt2++;
}
printf("%d\n",C(cnt2,cnt));
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 2ms
memory: 4364kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 2ms
memory: 4364kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 1ms
memory: 4364kb
input:
10 3 1 2 2 2 2 2 2 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: 0
Accepted
time: 2ms
memory: 4360kb
input:
10 3 1 1 0 1 2 3 2 2
output:
1
result:
ok 1 number(s): "1"
Test #5:
score: 0
Accepted
time: 2ms
memory: 4300kb
input:
10 3 2 2 2 2 2 2 2 2
output:
3
result:
ok 1 number(s): "3"
Test #6:
score: 0
Accepted
time: 2ms
memory: 4596kb
input:
10 3 2 1 1 1 1 2 2 3
output:
1
result:
ok 1 number(s): "1"
Test #7:
score: -3
Wrong Answer
time: 2ms
memory: 4536kb
input:
10 3 1 1 1 0 0 0 0 0
output:
3
result:
wrong answer 1st numbers differ - expected: '1', found: '3'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%