题目链接:http://lightoj.com/volume_showproblem.php?problem=1214
问b是不是可以整除a
∑ni=1(ai%b)=(∑ni=1ai)%b
sb题
#include <stdio.h>
#include <cstring>
using namespace std;
typedef long long LL;
char a[310];
LL b;
inline LL gt(int no){
return (LL)(a[no]-'0');
}
int main(void)
{
int t,cas=0;
scanf("%d",&t);
while(t--){
scanf("%s",a);
int la=strlen(a);
scanf("%lld",&b);
LL p=0;
b=b<0?-b:b;
printf("Case %d: ",++cas);
for(int i=0;i<la;i++)if(a[i]!='-'){p*=10;p+=gt(i);p%=b;}
if(p==0)puts("divisible");
else puts("not divisible");
}
return 0;
}