1214 - Large Division
Time Limit: 1 second(s) Memory Limit: 32 MB

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

Output for Sample Input

6

101 101

0 67

-101 101

7678123668327637674887634 101

11010000000000000000 256

-202202202202000202202202 -101

Case 1: divisible

Case 2: divisible

Case 3: divisible

Case 4: not divisible

Case 5: divisible

Case 6: divisible

sum忘记初始化错了好久,还是同余定理

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

  

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

  3. LightOJ 1214 Large Division

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

  4. 1214 - Large Division -- LightOj(大数取余)

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

  5. LightOJ 1214 Large Division 水题

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

  6. Light OJ 1214

    简单大数模拟题: #include<bits/stdc++.h> using namespace std; typedef long long ll; string Num; vector ...

  7. LightOJ1214 Large Division —— 大数求模

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

  8. LightOJ1214 Large Division

    /* LightOJ1214 Large Division http://lightoj.com/login_main.php?url=volume_showproblem.php?problem=1 ...

  9. Light OJ 1114 Easily Readable 字典树

    题目来源:Light OJ 1114 Easily Readable 题意:求一个句子有多少种组成方案 仅仅要满足每一个单词的首尾字符一样 中间顺序能够变化 思路:每一个单词除了首尾 中间的字符排序 ...

随机推荐

  1. 第一章、关于SQL Server数据库的备份和还原(sp_addumpdevice、backup、Restore)

    在sql server数据库中,备份和还原都只能在服务器上进行,备份的数据文件在服务器上,还原的数据文件也只能在服务器上,当在非服务器的机器上启动sql server客户端的时候,也可以通过该客户端来 ...

  2. [数论]ZOJ3593 One Person Game

    题意:一个人要从A走到B  只能走a布.b步.(a+b)步,可以往左或右走   问 最少要走几步,不能走到的输出-1 可以列出方程 $ax+by=A-B$ 或者 $ax+(a+b)y=A-B$ 或者 ...

  3. [mock]12月11日

    给出一个二叉搜索树的先序遍历,要求重新构造出这个二叉搜索树.一开始给出了一个递归的算法,指出复杂度有更优的解法.然后想出来一个O(n)的算法,就是使用一个栈,然后依次判断新的节点比原来的大还是小,然后 ...

  4. C# Winform应用程序占用内存较大解决方法整理

     微软的 .NET FRAMEWORK 现在可谓如火如荼了.但是,.NET 一直所为人诟病的就是“胃口太大”,狂吃内存,虽然微软声称 GC 的功能和智能化都很高,但是内存的回收问题,一直存在困扰,尤其 ...

  5. 107. Binary Tree Level Order Traversal II

    题目: Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from ...

  6. uva 11817 - Tunnelling the Earth

    题意:从地球上的一个点到另一个点,求两点的球面距离和直线距离之差.假定地球是正球体,半径为6371009米. #include<iostream> #include<cmath> ...

  7. GB2312 简体中文编码表

    GB 2312中对所收汉字进行了“分区”处理,每区含有94个汉字/符号.这种表示方式也称为区位码. 01-09区为特殊符号. 16-55区为一级汉字,按拼音排序. 56-87区为二级汉字,按部首/笔画 ...

  8. WinCE下VPN设置

    一.环境 1.      WinCE5.0+2004/2005/2006/2007补丁. 2.      3G拨号模块. 二.说明 1.      WinCE设备必须可以接入网络. 2.      支 ...

  9. 函数 buf_chunk_init

    http://www.tuicool.com/articles/3QbYfm http://www.360doc.com/content/13/1216/17/12904276_337644353.s ...

  10. OpenSSH 'child_set_env()'函数安全绕过漏洞

    漏洞版本: OpenSSH 6.x 漏洞描述: Bugtraq ID:66355 CVE ID:CVE-2014-2532 OpenSSH是一种开放源码的SSH协议的实现. OpenSSH " ...