lightoj--1214--Large Division(大数取余)
Time Limit: 1000MS | Memory Limit: 32768KB | 64bit IO Format: %lld & %llu |
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
水题一枚
#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(大数取余)的更多相关文章
- 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 ...
- LightOJ 1214 Large Division
Large Division Given two integers, a and b, you should check whether a is divisible by b or not. We ...
- LightOJ 1214 Large Division 水题
java有大数模板 import java.util.Scanner; import java.math.*; public class Main { public static void main( ...
- Large Division (大数求余)
Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...
- 1214 - Large Division -- LightOj(大数取余)
http://lightoj.com/volume_showproblem.php?problem=1214 这就是一道简单的大数取余. 还想还用到了同余定理: 所谓的同余,顾名思义,就是许多的数被一 ...
- light oj 1214 - Large Division
1214 - Large Division PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB G ...
- LightOJ1214 Large Division —— 大数求模
题目链接:https://vjudge.net/problem/LightOJ-1214 1214 - Large Division PDF (English) Statistics Forum ...
- POJ2635The Embarrassed Cryptographer(大数取余+素数筛选+好题)
题目链接 题意:K是由两个素数乘积,如果最小的素数小于L,输出BAD最小的素数,否则输出GOOD 分析 素数打表将 L 大点的素数打出来,一定要比L大,然后就开始枚举,只需K对 素数 取余 看看是否为 ...
- java大数取余
java大数取余: 类方法:BigInteger.divideAndRemainder() 返回一个数组,key = 0为商key = 1为余数 import java.util.*; import ...
- hdu 1226 bfs+余数判重+大数取余
题目: 超级密码 Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
随机推荐
- POJ——T1125 Stockbroker Grapevine
http://poj.org/problem?id=1125 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36045 ...
- Xdoclet + Ant自己主动生成Hibernate配置文件
在使用Hibernate的时候,过多的Hibernate配置文件是一个让人头疼的问题. 近期接触了Xdoclet这个工具. 它实际上就是一个自己主动代码生成的工具.Xdoclet不能单独执行,必须搭配 ...
- [Gatsby] Install Gatsby and Scaffold a Blog
In this lesson, you’ll install Gatsby and the plugins that give the default starter the ability to t ...
- POJ 1765 November Rain
题目大意: 有一些屋顶,相当于一些线段(不想交). 问每一条线段能够接到多少水,相对较低的屋顶能够接到高屋顶留下的水(如题图所看到的).因为y1!=y2,所以保证屋顶是斜的. 解题思路: 扫描线,由于 ...
- Android LaunchMode案例篇
首先感谢小伙伴的关注.然后祝愿广大的情侣们节日快乐! 在开发中有时会遇到这种场景,用户点击注冊.第一步,第二步,完毕注冊跳转到登录界面,不须要用户一步一步的返回到登录界面.这是怎么实现的呢? 案例:有 ...
- 关于Blog使用
1.网易博客http://inowtofuture.blog.163.com/blog/#m=0 使用时间:2011年8月-2012年2月 记录内容:主要记录本科參加ACM期间在POJ(北京大学OJ) ...
- HDOJ 5299 Circles Game 圆嵌套+树上SG
将全部的圆化成树,然后就能够转化成树上的删边博弈问题.... Circles Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- hdu1276(士兵队列训练问题) java集合水过
点击打开链接 有人说这题属于栈或者队列,个人认为说集合应该比較准确点. Problem Description 某部队进行新兵队列训练,将新兵从一開始按顺序依次编号.并排成一行横队,训练的规则例如以下 ...
- Javascript防冒泡事件与Event对象
防冒泡 防冒泡用到的就是event的属性和方法 function add2shop(e) { if (!e) var e = window.event; e.cancelBubble = true; ...
- nyoj--233--Sort it (水题)
Sort it 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 You want to processe a sequence of n distinct integer ...