比赛 |
20101119 |
评测结果 |
AATTTTTTTT |
题目名称 |
求和 |
最终得分 |
20 |
用户昵称 |
wangwangdog |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-19 10:44:24 |
显示代码纯文本
#include<stdio.h>
long n,i,p,q,a[100001],min,k,pp,s[100001],j;
int main()
{
FILE *fin,*fout;
fin=fopen("suma.in","rb");
fout=fopen("suma.out","wb");
fscanf(fin,"%ld%ld%ld\n",&n,&k,&p);
for(i=1;i<=n;i++)
{
fscanf(fin,"%ld\n",&a[i]);
}
q=0;
for(i=1;i<=n;i++)
{
q=q+a[i];
s[i]=q;
}
min=2100000000;
for(i=1;i<=n;i++)
for(j=i;j<=n;j++)
{
if((s[j]-s[i]+a[i])%p>=k&&(s[j]-s[i]+a[i])%p<min)min=(s[j]-s[i]+a[i])%p;
}
fprintf(fout,"%ld",min);
fclose(fin);
fclose(fout);
return 0;
}