/*
大数除法
*/
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
typedef long long ll;
const int maxn = 222;
using namespace std;
char a[maxn];
int b;
vector<ll> ve;
int Divisible()
{
int size = ve.size()-1;
for(int i = 0; i <=size;i++)
{
ll x = (ve[i]%b)*10;
if(x!=0 && i==size)return 0;
if(i+1<=size)
ve[i+1] += x;
}
return 1;
}
int main()
{
int t,i;
scanf("%d",&t);
for(int cas = 1; cas <= t; cas++)
{
scanf("%s%d",a,&b);
ve.clear();
i = 0;
if(a[i]=='-')i++;
for(;a[i];i++)
ve.push_back(a[i]-'0');
if(b<0)b=-b;
printf("Case %d: ",cas);
if(Divisible())puts("divisible");
else puts("not divisible");
}
return 0;
}
数学_Lightoj_1214大数整出
最新推荐文章于 2024-02-13 21:09:09 发布