Large Division

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 (-10^200 ≤ a ≤ 10^200) 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

可以用JAVA:

import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t=in.nextInt();
int sum;
sum=0;
BigInteger a,b;
BigInteger c=BigInteger.valueOf(0);
while(t-->0) {
sum++;
a=in.nextBigInteger();
b=in.nextBigInteger();
if(a.remainder(b).equals(c)) //equal括号内的数据类型必须是大整数类的,不能是int类型的。
System.out.println("Case "+sum+": divisible");
else
System.out.println("Case "+sum+": not divisible");
}
}
}

(大数 求余) Large Division Light OJ 1214的更多相关文章

  1. POJ 2635 The Embarrassed Cryptographer(大数求余)

    题意:给出一个大数,这个大数由两个素数相乘得到,让我们判断是否其中一个素数比L要小,如果两个都小,输出较小的那个. 分析:大数求余的方法:针对题目中的样例,143 11,我们可以这样算,1 % 11 ...

  2. 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 ...

  3. light oj 1214 - Large Division

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

  4. Large Division (大数求余)

    Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...

  5. Light OJ 1214

    简单大数模拟题: #include<bits/stdc++.h> using namespace std; typedef long long ll; string Num; vector ...

  6. Project Euler 48 Self powers( 大数求余 )

    题意: 项的自幂级数求和为 11 + 22 + 33 + - + 1010 = 10405071317. 求如下一千项的自幂级数求和的最后10位数字:11 + 22 + 33 + - + 100010 ...

  7. POJ2635-The Embarrassed Cryptographer 大数求余

    题目链接:http://poj.org/problem?id=2635 题目分析: http://blog.csdn.net/lyy289065406/article/details/6648530

  8. 大数求模 sicily 1020

        Search

  9. 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem (大数取余)

    Problem Descripton Two planets named Haha and Xixi in the universe and they were created with the un ...

随机推荐

  1. cocoapod Podfile use frameworks swift/oc混编 could not build module xxx

    前置: 知名的pod: AFNetworking 我自己的pod:  AFNetworking+RX  3.1.0.18 里面有一段代码是: #import <Foundation/Founda ...

  2. 实验1--用C语言编程四则运算

    #include<stdio.h>#include<stdlib.h>#include <time.h>#define N 30main(){int a,b,k,i ...

  3. MySQL服务器监控注意事项

    当开发,测试,生产的数据库环境配置不一致(比如:配置字符集不同)时而导致特殊现象时,可以从Navicat的<工具>-<服务器监控>-<变量>里查找原因.

  4. [转帖] select、poll、epoll之间的区别总结[整理] + 知乎大神解答 https://blog.csdn.net/qq546770908/article/details/53082870 不过图都裂了.

    select.poll.epoll之间的区别总结[整理] + 知乎大神解答 2016年11月08日 15:37:15 阅读数:2569 http://www.cnblogs.com/Anker/p/3 ...

  5. 【转帖】intel 2018年1 月2号爆出漏洞分析 知乎匿名用户

    作者:匿名用户链接:https://www.zhihu.com/question/265012502/answer/288407097来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载 ...

  6. 搭建Spark所遇过的坑

    一.经验 1.Spark Streaming包含三种计算模式:nonstate .stateful .window 2.kafka可通过配置文件使用自带的zookeeper集群 3.Spark一切操作 ...

  7. Node http和express和mysql

    const http = require("http");const express = require("express");const mysql = re ...

  8. JavaScript中的Date对象在IOS中的“大坑”

    在IOS5以上版本(不包含IOS5)中的Safari浏览器能正确解释出Javascript中的 new Date('2013-10-21') 的日期对象. 但是在IOS5版本里面的Safari解释ne ...

  9. Mac上brew&thrift安装 以及在thrift架构下,自己新作了maven的小例 Demo

    1.缘由 前几天偶尔在网上看到thrift的信息,其内容和作用极大的引起了我的兴趣,因为我也是做iOS开发的,通过在网上的查询发现信息虽然很多实用的很少,容易误导他人,经过自己的成功实践,做了笔录,为 ...

  10. Java之数组遍历

    package basic; //数组遍历方法 public class ForEach { public static void main(String[] args) { // 原始数组 Stri ...