(大数 求余) 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 ...
随机推荐
- cf946d 怎样逃最多的课dp
来源:codeforces D. Timetable Ivan is a student at Berland ...
- @Scheduled 定时
此文章记录在spring boot项目中的使用 1,在项目的启动类中加注解@EnableScheduling,表示此项目可以进行定时 @SpringBootApplication @EnableSch ...
- Word frequency program ver.1
先吐槽一下自己 做这个作业的时候完全没有提前考虑好时间 导致要提交前一天晚上通宵写代码 而且还满满的bug TAT 缓一口气 程序还在继续写 先把有点累 想着先把博客写了 PART I 预计时间: 语 ...
- 《Linux内核设计与实现》读书笔记三
Chapter 18 调 试 18.1 准备开始 1.准备工作: 一个bug 一个藏匿bug的内核版本 相关内核代码的知识和运气 2.执行foo就会让程序立即产生核心信息转储(dump core). ...
- spring播放器详细设计说明书(一)
1 引言 1.1编写目的 编写目的是详细说明SPRING音乐播放器的设计使用,预期读者对象为在个人电脑上需要使用简单音乐播放器的用户.1.2项目背景 说明: a.待开发软件系统的名称为SPRING音 ...
- Docker查看容器IP
https://segmentfault.com/q/1010000001637726 https://blog.csdn.net/sannerlittle/article/details/77063 ...
- vue$ref
vue的$ref方法 可以在元素上template中直接添加ref属性 类似html的id属性 用来做选项卡的切换的
- [日常工作] SUSE设置上网ip地址
1. 同事搜到的命令 ifconfig eth0 10.24.25.8 netmask 255.255.0.0 up route add default gw 10.24.255.254 2. 修改 ...
- Node fs模块异步读取验证并异步写入
console.log("1:开始读成取文件内容...");fs.readFile('./public/2.log',function(err,data){ if(err){ co ...
- SQL Server 常用函数使用方法(持续更新)
之前就想要把一些 SQL 的常用函数记录下来,不过一直没有实行...嘿嘿... 直到今天用到substring()这个函数,C# 里面这个方法起始值是 0,而 SQL 里面起始值是 1.傻傻分不清楚. ...