QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#118540 | #6625. Binaria | zhouhuanyi | 0 | 2ms | 4580kb | C++11 | 1.3kb | 2023-07-03 17:05:03 | 2023-07-03 17:05:05 |
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 (i%k!=k-1)
{
if (s[i]+1==s[i+1]) used[i%k]=1;
if (s[i]-1==s[i+1]) used2[i%k]=1;
}
else
{
if (a[n]+s[i+1]-s[i]==0) used[i%k]=1;
if (a[n]+s[i+1]-s[i]==2) 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;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 3
Accepted
time: 0ms
memory: 4364kb
input:
1 1 0
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: 0
Accepted
time: 2ms
memory: 4376kb
input:
1 1 1
output:
1
result:
ok 1 number(s): "1"
Test #3:
score: 0
Accepted
time: 2ms
memory: 4580kb
input:
10 3 1 2 2 2 2 2 2 2
output:
2
result:
ok 1 number(s): "2"
Test #4:
score: -3
Wrong Answer
time: 2ms
memory: 4312kb
input:
10 3 1 1 0 1 2 3 2 2
output:
0
result:
wrong answer 1st numbers differ - expected: '1', found: '0'
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%