0
点赞
收藏
分享

微信扫一扫

K - Large Division

史值拥 2022-08-22 阅读 68


​​K - Large Division ​​

一开始用的是队列,然后编译器总是在队列那里报错,不是很明白啥情况,然后这道题不用队列也可以写出来,所就默默改成不是队列的。

这题恩,明白了char数组可以直接这样输入,

char a[100];
scanf("%s",a);
//计算数组的长度可以是
strlen(a);

AC程序

#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
//模拟除法运算
using namespace std;
int main()
{
int t;
long long b;
char a[210];
cin >> t;
for (int i = 1; i <= t; i++){
scanf_s("%s%lld", a, &b);
b = abs(b);
long long temp = 0;
for (int j = 0; j < strlen(a); j++)//emmm这个sizeof
{
if (a[j] == '-')
continue;
temp = temp * 10 + (a[j] - '0');
temp %= b;
}
//temp %= b;
if (temp == 0)
printf("Case %d: divisible\n", i);
else
printf("Case %d: not divisible\n", i);

}
return 0;
}


举报

相关推荐

0 条评论