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. Mysql存储结构

    索引是一种加快查询速度的数据结构,常用索引结构有hash.B-Tree和B+Tree.本节通过分析三者的数据结构来说明为啥Mysql选择用B+Tree数据结构. 数据结构 Hash hash是基于哈希 ...

  2. springboot集成mongodb实现动态切换数据源

    主要实现原理,利用spring的aop 在切入点执行db操作之前 将数据库切换: 本例子采用aop在controller进行拦截 拦截到MongoTemplate.class 切换数据源后重新放回去 ...

  3. 推荐:实现RTSP/RTMP/HLS/HTTP协议的轻量级流媒体框架,支持大并发连接请求

    推荐一个比较好用的流媒体服务开源代码: ZLMediaKit: 实现RTSP/RTMP/HLS/HTTP协议的轻量级流媒体框架,支持大并发连接请求 https://gitee.com/xiahcu/Z ...

  4. .NETCore微服务探寻(三) - 远程过程调用(RPC)

    前言 一直以来对于.NETCore微服务相关的技术栈都处于一个浅尝辄止的了解阶段,在现实工作中也对于微服务也一直没有使用的业务环境,所以一直也没有整合过一个完整的基于.NETCore技术栈的微服务项目 ...

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

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

  6. GitLab Admin Area 500 Error

    GitLab Admin Area 500 Error GitLab Admin Area Settings 菜单全部报错 500 解决方法 执行: gitlab-rake cache:clear # ...

  7. 痞子衡嵌入式:了解i.MXRTxxx系列ROM API及其与i.MXRT1xxx系列的差异

    大家好,我是痞子衡,是正经搞技术的痞子.今天痞子衡给大家介绍的是i.MXRTxxx系列ROM API设计细节. 痞子衡之前写过两篇文章 <利用i.MXRT1xxx系列ROM提供的FlexSPI ...

  8. springboot中redis的缓存穿透问题

    什么是缓存穿透问题?? 我们使用redis是为了减少数据库的压力,让尽量多的请求去承压能力比较大的redis,而不是数据库.但是高并发条件下,可能会在redis还没有缓存的时候,大量的请求同时进入,导 ...

  9. C#算法设计排序篇之05-归并排序(附带动画演示程序)

    归并排序(Merge Sort) 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/683 访问. 归并排序是建立在归并操作 ...

  10. C#LeetCode刷题之#237-删除链表中的节点(Delete Node in a Linked List)

    问题 该文章的最新版本已迁移至个人博客[比特飞],单击链接 https://www.byteflying.com/archives/3832 访问. 请编写一个函数,使其可以删除某个链表中给定的(非末 ...