Find Tutorial Here: Big Integer Remainder
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
long long int n,r,t,j,i,m;
//freopen("1214.txt","r",stdin);
//freopen("1214out.txt","w",stdout);
cin>>t;
for(i=1;i<=t;i++)
{
cin>>s>>n;
r=0;
//cout<<n<<endl;
if(n<0)
{
m=n*(-1);
//cout<<m<<endl;
}
else
{
m=n;
}
for(j=0;j<s.length();j++)
{
if(s[j]!='-')
{
r=((r*10)+(s[j]-'0'))%m;
}
}
// cout<<r<<endl;
if(r==0)
{
printf("Case %lld: divisible\n",i);
}
else
{
printf("Case %lld: not divisible\n",i);
}
}
return 0;
}
0 comments:
Post a Comment