Bismillahir Rahmanir Rahim
///Author: Tanvir Ahmmad
///CSE,Islamic University,Bangladesh
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<cmath>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<iterator>
#include <functional> ///sort(arr,arr+n,greater<int>()) for decrement of array
/*every external angle sum=360 degree
angle find using polygon hand(n) ((n-2)*180)/n*/
///Floor[Log(b) N] + 1 = the number of digits when any number is represented in base b
using namespace std;
typedef long long ll;
typedef long long unsigned llu;
void ans(string str,llu div,int ca)
{
int sz=str.size();
llu num=0;
for(int i=0; i<sz; i++)
{
if(str[i]=='-') continue;
num=(num*10)+(str[i]-'0');
num%=div;
}
if(num<=1) printf("Case %d: divisible\n",ca);
else printf("Case %d: not divisible\n",ca);
}
int main()
{
int tst;
scanf("%d",&tst);
for(int i=1; i<=tst; i++)
{
string str,str1;
cin>>str>>str1;
int sz=str1.size();
llu div=0;
for(int j=0; j<sz; j++)
{
if(str1[j]=='-') continue;
div=(div*10)+(str1[j]-'0');
}
ans(str,div,i);
}
return 0;
}
///Alhamdulillah
Problem Link: https://lightoj.com/problem/large-division
Comments
Post a Comment