8.18下午高精除

This commit is contained in:
ljcjames 2022-08-18 16:52:32 +08:00
parent 6429be5a4b
commit 1e5c764043
1 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#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;
}