Given two integers, a and b, you should check whether a is divisible by b or not. We know that an integer a is divisible by an integer b if and only if there exists an integer c such that a = b * c.

Input

Input starts with an integer T (≤ 525), denoting the number of test cases.

Each case starts with a line containing two integers a (-10200 ≤ a ≤ 10200) and b (|b| > 0, b fits into a 32 bit signed integer). Numbers will not contain leading zeroes.

Output

For each case, print the case number first. Then print 'divisible' if a is divisible by b. Otherwise print 'not divisible'.

Sample Input

6

101 101

0 67

-101 101

7678123668327637674887634 101

11010000000000000000 256

-202202202202000202202202 -101

Sample Output

Case 1: divisible

Case 2: divisible

Case 3: divisible

Case 4: not divisible

Case 5: divisible

Case 6: divisible

代码:

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<map>
#include<cmath>
const int maxn=1e5+;
typedef long long ll;
using namespace std;
char str[];
int main()
{
int T;
cin>>T;
int b;
int cnt=;
while(T--)
{
scanf("%s",str);
scanf("%d",&b);
if(b<)
b=-b;
int len=strlen(str);
ll ans=;
for(int t=;t<len;t++)
{
if(str[t]>=''&&str[t]<='')
{
ans=((ans*)+(str[t]-''))%b;
}
else
{
continue;
}
}
printf("Case %d: ",cnt++);
if(ans==)
{
puts("divisible");
}
else
{
puts("not divisible");
}
}
return ;
}
import java.math.BigInteger;
import java.util.Scanner; public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int T;
int cnt=1;
T=sc.nextInt();
while(T>=0)
{
BigInteger a,b,c;
a=sc.nextBigInteger();
b=sc.nextBigInteger();
a=a.abs();
b=b.abs(); System.out.print("Case "+cnt+":");
if(a.remainder(b).equals(BigInteger.ZERO))
{
System.out.println(" divisible");
}
else
{
System.out.println(" not divisible");
}
T--;
cnt++;
} } }
import java.math.BigInteger;
import java.util.Scanner; public class Main { public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int T;
int cnt=1;
T=sc.nextInt();
while(T>=0)
{
BigInteger a,b,c; a=sc.nextBigInteger();
b=sc.nextBigInteger();
a=a.abs();
b=b.abs();
System.out.print("Case "+cnt+":"); if(a.gcd(b).equals(b))
{
System.out.println(" divisible");
}
else
{
System.out.println(" not divisible");
}
T--;
cnt++;
} } }

LightOJ - 1214-Large Division(c++取模 + java的两种写法)的更多相关文章

  1. LightOJ 1214 Large Division

    Large Division Given two integers, a and b, you should check whether a is divisible by b or not. We ...

  2. LightOJ 1214 Large Division 水题

    java有大数模板 import java.util.Scanner; import java.math.*; public class Main { public static void main( ...

  3. java路径两种写法"/"和"\\"

    String path="D:\\新建文件夹\\2.png"; File file=new File(path); System.out.println(file.exists() ...

  4. LightOJ1214 Large Division —— 大数求模

    题目链接:https://vjudge.net/problem/LightOJ-1214 1214 - Large Division    PDF (English) Statistics Forum ...

  5. light oj 1214 - Large Division

    1214 - Large Division   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB G ...

  6. light oj 1214 - Large Division 大数除法

    1214 - Large Division Given two integers, a and b, you should check whether a is divisible by b or n ...

  7. java中两种类型变量

    Java中有两种类型的变量,一种是对象类型,另一种是基础类型(primitive type). 对象类型普遍采用引用的方式,比如 List a = new ArrayList(); List b = ...

  8. JAVA 中两种判断输入的是否是数字的方法__正则化_

    JAVA 中两种判断输入的是否是数字的方法 package t0806; import java.io.*; import java.util.regex.*; public class zhengz ...

  9. Java中两种实现多线程方式的对比分析

    本文转载自:http://www.linuxidc.com/Linux/2013-12/93690.htm#0-tsina-1-14812-397232819ff9a47a7b7e80a40613cf ...

随机推荐

  1. 十分钟搭建自己的私有NuGet服务器-BaGet

    目录 前言 开始 搭建BaGet 上传程序包 在vs中使用 其他 最后 前言 NuGet是用于微软.NET(包括 .NET Core)开发平台的软件包管理器.NuGet能够令你在项目中添加.移除和更新 ...

  2. IDEA使用GsonFormat

    安装GsonFormat插件 因为下载了最新版的idea2020.1.3发现GsonFormat在Idea商店不见了,所以去jetbrains官网下载jar包来安装插件https://plugins. ...

  3. wps 2011 破解版软件

    今天换了一台新电脑. wps 都没有 系统的太过忍受不了 整了一天终于是找到了一个合适安装的 想要的邮件发给我  673658917@qq.com

  4. python6.3类的继承与多态

    class Animal(object): def __init__(self,color): self.color=color def eat(self): print("动物在吃!&qu ...

  5. C语言学习笔记之输出缓冲

    在c语言中经常用到输出函数printf,当我们像往常一样在输出函数中输入我们的想要的输出的东西后加\n换行 验证结果如我们输出的一样 如果我们在后面加入死循环会不会出现这些语句呢 结果卡死了,可还是输 ...

  6. CSS表单与数据表(上)

    表单在现代Web应用中占据着重要地位. 表单可以很简单,也可以非常复杂,要横跨几个页面. 除了从用户哪里获得数据,Web应用还需要以容易看懂的方式展示数据.表格是展示复杂数据的最佳方式. 1.设计数据 ...

  7. 一个试图了解JVM内存模型的两年经验的初级程序员,透彻!

    所有的编程语言中都有内存模型这个概念,区别于微架构的内存模型,高级语言的内存模型包括了编译器和微架构两部分.我试图了解了Java.C#和Go语言的内存模型,发现内容基本大同小异,只是这些语言在具体实现 ...

  8. csapp第九章笔记-虚拟内存

    目录 物理与虚拟寻址 地址空间 虚拟内存作为缓存的工具 虚拟内存作为内存管理的工具 虚拟内存作为内存保护的工具 地址翻译 使用TLB(翻译后备缓冲器)加速地址翻译 多级页表 物理与虚拟寻址 计算机系统 ...

  9. 2020-06-02:千万级数据量的list找一个数据。

    福哥答案2020-06-02: 对于千万级长度的数组单值查找:序号小的,单线程占明显优势:序号大的,多线程占明显优势.单线程时间不稳定,多线程时间稳定. go语言测试代码如下: package mai ...

  10. Vue 使用v-for对Object进行遍历

    v-for 也可以对Object类型数据进行遍历 value在前, key在后 <div v-for="(value,key) in person"> <p> ...