Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu

Submit
Status

Description

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

Source

Problem Setter: Jane Alam Jan



水题一枚

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
char s[1001];
int main()
{
int t,k=1;
scanf("%d",&t);
while(t--)
{
memset(s,'\0',sizeof(s));
scanf("%s",s);
long long mod,temp;
scanf("%lld",&mod);
temp=0;
for(int i=0;i<strlen(s);i++)
{
if(s[i]=='-') continue;
temp=temp*10+(s[i]-'0');
temp%=mod;
}
if(temp%mod)
printf("Case %d: not divisible\n",k++);
else
printf("Case %d: divisible\n",k++);
}
return 0;
}

lightoj--1214--Large Division(大数取余)的更多相关文章

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

  2. LightOJ 1214 Large Division

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

  3. LightOJ 1214 Large Division 水题

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

  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. 1214 - Large Division -- LightOj(大数取余)

    http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...

  6. light oj 1214 - Large Division

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

  7. LightOJ1214 Large Division —— 大数求模

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

  8. POJ2635The Embarrassed Cryptographer(大数取余+素数筛选+好题)

    题目链接 题意:K是由两个素数乘积,如果最小的素数小于L,输出BAD最小的素数,否则输出GOOD 分析 素数打表将 L 大点的素数打出来,一定要比L大,然后就开始枚举,只需K对 素数 取余 看看是否为 ...

  9. java大数取余

    java大数取余: 类方法:BigInteger.divideAndRemainder() 返回一个数组,key = 0为商key = 1为余数 import java.util.*; import ...

  10. hdu 1226 bfs+余数判重+大数取余

    题目: 超级密码 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

随机推荐

  1. 洛谷 P1529 回家 Bessie Come Home

    P1529 回家 Bessie Come Home 题目描述 现在是晚餐时间,而母牛们在外面分散的牧场中. 农民约翰按响了电铃,所以她们开始向谷仓走去. 你的工作是要指出哪只母牛会最先到达谷仓(在给出 ...

  2. 洛谷 P3576 [POI2014]MRO-Ant colony

    P3576 [POI2014]MRO-Ant colony 题目描述 The ants are scavenging an abandoned ant hill in search of food. ...

  3. javase复习

    一.总结封装 封装就是将数据和操作数据的方法绑定起来,通过private修饰数据,这样对数据的访问只能通过定义的操作数据的方法get/set来操作数据. 封装优点:1.由于将数据进行了封装,隐藏了不必 ...

  4. [hihocoder #1384] Genius ACM 解题报告(倍增)

    题目链接:http://hihocoder.com/problemset/problem/1384 题目大意: 给定一个整数 M,对于任意一个整数集合 S,定义“校验值”如下: 从集合 S 中取出 M ...

  5. winforms控件

     我们在开发窗体应用时,控件是必不可少的今天我们就来认识一下控件 在认识控件之前还要先来认识一下窗体具体如下: 认识窗体和控件 窗体                                   ...

  6. JavaScript学习——使用JS完成省市二级联动

    1.我们希望在注册页面中添加一个字段(籍贯),当用户选择一个具体的省份,在后面的下拉列表中动态加载该省份下所有的城市.显示的效果如下: 2.步骤分析: 第一步:确定事件(onchange)并为其绑定一 ...

  7. POJ 3067 Japan 【 树状数组 】

    题意:左边有n个城市,右边有m个城市,现在修k条路,问会形成多少个交点 先按照x从小到大排,x相同的话,则按照y从小到大排,然后对于每一个y统计前面有多少个y比它大,它们就一定会相交 另外要用long ...

  8. 设置fixed,横向滚动条失效

    window.onscroll = function(){ var sl = -Math.max(document.body.scrollLeft,document.documentElement.s ...

  9. grant 命令

    创建拥有所有权限账户.可以远程连接.并且允许用户再将该权限授予其它用户: grant all privileges on *.* to root @"%" identified b ...

  10. org.apache.ibatis.binding.BindingException: Parameter ‘brOrderNo’ not found. Available parameters ar

    最近使用 mybatis 写项目的时候遇到报错:org.apache.ibatis.binding.BindingException: Parameter 'brOrderNo' not found. ...