(大数 求余) Large Division Light OJ 1214
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的更多相关文章
- POJ 2635 The Embarrassed Cryptographer(大数求余)
题意:给出一个大数,这个大数由两个素数相乘得到,让我们判断是否其中一个素数比L要小,如果两个都小,输出较小的那个. 分析:大数求余的方法:针对题目中的样例,143 11,我们可以这样算,1 % 11 ...
- 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 ...
- light oj 1214 - Large Division
1214 - Large Division PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB G ...
- Large Division (大数求余)
Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...
- Light OJ 1214
简单大数模拟题: #include<bits/stdc++.h> using namespace std; typedef long long ll; string Num; vector ...
- Project Euler 48 Self powers( 大数求余 )
题意: 项的自幂级数求和为 11 + 22 + 33 + - + 1010 = 10405071317. 求如下一千项的自幂级数求和的最后10位数字:11 + 22 + 33 + - + 100010 ...
- POJ2635-The Embarrassed Cryptographer 大数求余
题目链接:http://poj.org/problem?id=2635 题目分析: http://blog.csdn.net/lyy289065406/article/details/6648530
- 大数求模 sicily 1020
Search
- 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem (大数取余)
Problem Descripton Two planets named Haha and Xixi in the universe and they were created with the un ...
随机推荐
- 牛客训练赛25-A-因数个数
题目链接https://www.nowcoder.com/acm/contest/158/A 无语...这题很迷啊,原谅我的菜,刚开始想用预处理欧拉筛和前缀和,可是这题太血崩了,这样一样要遍历,1-e ...
- HDU 3537 Daizhenyang's Coin
链接 [http://acm.hdu.edu.cn/showproblem.php?pid=3537] 题意 题意:已知一排硬币中有n个硬币正面朝上,输入正面朝上的硬币的位置ai.两人轮流操作, 每次 ...
- mac系统下修复第三方Python包bug
发现问题 今天在github上fork了CI 3.x的中文手册,按照README文档一步步进行Sphinx和相关工具的安装,最终build生成html版手册.操作到第6步执行`make html`的时 ...
- 软件工程(四)数据流图DFD
结构化分析中,常用到数据模型为实体关系图,功能模型是数据流图 DFD 可以认为,一个基于计算机的信息处理系统由数据流和一系列的转换构成,这些转换将输入数据流变换为输出数据流.数据流图就是用来刻画数据流 ...
- GitLab添加ssh-key,操作无需每次输入账号密码
git config --global credential.helper store 然后操作pull/push 会让输入用户名密码,第一次输入进去.下次再操作pull/push时就不需要输入用户名 ...
- php实现常驻进程 多进程监控
php都是通过crontabd定时脚本处理队列的,面试被问到php如何常驻进程进行处理队列,想了半天这样不知道是否是一种方式 <?php function logs(){ file_put_co ...
- jquery Ajax noConflict()
如果幾個框架都在使用$作為標識符,那麼這個時候可以使用noConflict()處理衝突. 可以直接使用jquery代替簡寫,也可以定義變量,也可以將$賦值給ready函數,函數內部可以使用快捷方式,不 ...
- BZOJ4832[Lydsy1704月赛]抵制克苏恩——期望DP
题目描述 小Q同学现在沉迷炉石传说不能自拔.他发现一张名为克苏恩的牌很不公平.如果你不玩炉石传说,不必担心,小Q 同学会告诉你所有相关的细节.炉石传说是这样的一个游戏,每个玩家拥有一个 30 点血量的 ...
- BZOJ4378[POI2015]Logistyka——树状数组
题目描述 维护一个长度为n的序列,一开始都是0,支持以下两种操作:1.U k a 将序列中第k个数修改为a.2.Z c s 在这个序列上,每次选出c个正数,并将它们都减去1,询问能否进行s次操作.每次 ...
- s - t 平面图最大流 (附例题 bzoj 1001)
以下均移自 周冬的<两极相通-浅析最大最小定理在信息学竞赛中的应用> 平面图性质 1.(欧拉公式)如果一个连通的平面图有n个点,m条边和f个面,那么f=m-n+2 2.每个平面图G都有一个 ...