47 lines
876 B
C++
47 lines
876 B
C++
#include <iostream>
|
||
#include<cstdio>
|
||
#include<algorithm>
|
||
#include <cmath>
|
||
#include <cstring>
|
||
using namespace std;
|
||
const int S=205;
|
||
char s[S];
|
||
long long a[S];//´Ó1¿ªÊ¼
|
||
int main()
|
||
{
|
||
int t;
|
||
int t1=0;
|
||
int len;
|
||
long long b;
|
||
char c1;
|
||
scanf("%d",&t);
|
||
while(t--)
|
||
{
|
||
a[0]=0;//important
|
||
scanf("%s%lld",&s,&b);//lld
|
||
len=strlen(s);
|
||
for(int i=1;i<len; i++)
|
||
{
|
||
a[len-i]=s[i]-'0';
|
||
}
|
||
if(s[0]=='-')len--;
|
||
else a[len]=s[0]-'0';
|
||
if(b<0)b*=-1;
|
||
for(int i=len;i>0; i--)
|
||
{
|
||
a[i]%=b;
|
||
a[i-1]+=(a[i]*10);
|
||
// printf("%d ",a[i-1]);
|
||
}
|
||
if(a[0]==0)
|
||
{
|
||
printf("Case %d: divisible\n",++t1);
|
||
}
|
||
else
|
||
{
|
||
printf("Case %d: not divisible\n",++t1);
|
||
}
|
||
}
|
||
return 0;
|
||
}
|