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 <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f3f
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
char a[];
ll b,t,ans;
int main()
{
scanf("%d",&t);
int k=t;
while(t--)
{
scanf("%s %lld",a,&b);
b=abs(b);
printf("Case %d: ",k-t);
ans=;
for(int i=;i<strlen(a);i++)
{
if(a[i]=='-') continue;
ans=ans*+(a[i]-'');
ans=ans%b;
if(ans==) {puts("divisible");goto end;}
}
puts("not divisible");
end:;
}
return ;
}

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

  1. LightOJ1214 Large Division —— 大数求模

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

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

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

  3. (大数 求余) 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 ...

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

  5. L - Large Division (大数, 同余)

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

  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. .Net 跳转

    Action正常跳转 <a href="@Url.Action("AppDownload")">点击下载APP</a> public A ...

  2. quartz-misfire 错失、补偿执行

    调度(scheduleJob)或恢复调度(resumeTrigger,resumeJob)后不同的misfire对应的处理规则 misfire产生的条件是:到了该触发执行时上一个执行还未完成,且线程池 ...

  3. 源码编译安装Nginx全程视频演示

    基本步骤: 1.首先停止现有web系统, #/etc/init.d/apache2 stop 2.将源码拷贝到/usr/local/src #cp /home/ditatompel/Public/Ng ...

  4. 新手教程:电信+广电(或其他运营商)双WAN设置

    由于国内不同运营商之间互联互通存在问题,假如用联通的线路去访问电信的站点那么会比较卡,反之亦然:所以如果两个WAN的线路不是同一个运营商,一般都是建议用户双WAN模式选为“智能路由”.经过本人测试发现 ...

  5. JSP中 input type 用法

    JSP中 input type 用法 Input表示Form表单中的一种输入对象,其又随Type类型的不同而分文本输入框,密码输入框,单选/复选框,提交/重置按钮等,下面一一介绍. 1,type=te ...

  6. JS的解析与执行过程—全局预处理阶段之命名冲突的处理策略

    有如下代码: <body> <script> alert(f); function f() { console.log("fff"); } var f = ...

  7. 彻底分析虚拟视频驱动vivi(三)

    在Ubuntu系统中接上usb摄像头设备时,系统会自动安装对应的usb设备驱动程序.我们现在要使用自己编译的vivi驱动,该怎么办呢? 1.先安装系统自带的vivi驱动和它所依赖的所有驱动:sudo ...

  8. 实现IE下兼容CSS3的圆角效果

    有些CSS3的牛逼的效果在IE下展示不出来是最烦人的啦,在项目中做的圆角效果到了IE下一堆方块....忒尴尬了...,找了个替代解决方案 1.首先下载一个js插件PIE.js百度一搜都是的,我也就不写 ...

  9. 【Henu ACM Round#17 E】Tree Construction

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 做这题之前先要知道二叉排序树的一个性质. 就是它的中序遍历的结果就是这个数组升序排序. (且每个节点的左边的节点都是比这个节点的值小 ...

  10. 如何分解json值设置到text文本框中

    <td><input type="text" id="name11"></td> //4设置访问成功返回的操作 xhr.on ...