这道题就是高精度取余的做法,能不能整除,其实正负并没有影响,所以直接高精度取余判断非0就好了
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define fin(a,n) for(int i=a;i<=n;i++)
const int maxn=250;
int f(string a,ll b)
{ ll ans=0;
int na[maxn];
int lena=a.size();
fin(0,a.size()-1)
{ if(a[i]=='-')continue;
ans=(a[i]-'0'+ans*10)%b;
}
return ans;
}
int main()
{
int n;
scanf("%d",&n);
for(int cas=1;cas<=n;cas++)
{
string a;ll b;
cin>>a>>b;
if(f(a,b))printf("Case %d: not divisible\n",cas);
else printf("Case %d: divisible\n",cas);
}
}