Description
Input
Output
Sample Input
Sample Output
#include<stdio.h>
main()
{int x[100008];
int n,k,i,s,sum,m,z,t;
while(scanf("%d %d",&n,&k)!=EOF)
{z=0;
for(i=1;i<=n;i++)
{
scanf("%d",&x[i]);
}
for(i=n+1;i<=2*n;i++)
{
x[i]=x[i-n];
}
for(m=1;m<=n;m++)
{sum=x[m];
if(sum%k==0)
z++;
for(i=1;i<n;i++)
{
sum=sum*10+x[m+i];
if(sum%k==0)
z++;
}
}
printf("%d\n",z);}
}
暂时不会优化的算法,以后有时间在完善吧。,布布扣,bubuko.com
原文地址:http://www.cnblogs.com/alexanderone/p/3854897.html