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 ...
随机推荐
- ASP.NET-internat身份验证
ASP.NET-internat身份验证默认在webconfig中配置的代码是这样的 <system.web> <compilation debug="true" ...
- 每天学点Python之comprehensions
每天学点Python之comprehensions 推导式能够简化对数据的处理,让代码简洁的同一时候还具有非常高的可读性.这在Python中非经常见. 列表推导式 通过列表推导式能够对列表中的全部元素 ...
- [LeetCOde][Java] Best Time to Buy and Sell Stock III
题目: Say you have an array for which the ith element is the price of a given stock on day i. Design a ...
- ORA-01950: 表空间'USERS'中无权限的2种解决办法
在创建了一个新的表空间和一个新的用户,当用这个新用户创建表时, 却出现:ORA-01950: 表空 间'USERS'中无权限. 我已经把创建表的权限赋给了此用户,怎么还会缺少权限呢?解决办法 ...
- Java TreeMap 介绍和使用
转自:https://www.cnblogs.com/skywang12345/p/3310928.html 概要 这一章,我们对TreeMap进行学习. 我们先对TreeMap有个整体认识,然后再学 ...
- Apache Ignite - 轉
Ignite Docs Online: ignite-doc-cn https://dongwq.gitbooks.io/ignite-doc/content/index.html - Apache ...
- [Java] Protect, Private and Public的区别
Java中的private.protected.public和default的区别 (2014-03-21 22:29:14) 转载▼ 标签: java java修饰符 it (1)对于publi ...
- Spring boot配置404、500页面
Spring boot 配置404页面很简单,如果你访问的url没有找到就会出现spring boot 提示的页面,很明显Spring boot不用配置就可以显示404页面了. 在template下创 ...
- Hibernate中如何完成持久化类和数据库映射文件
因为最近写项目需要要到,就在这里码码字,方便以后做一个参考,在这里,我通过的是myeclipse的反向工程来配置持久化类和数据的映射文件的. 1.打开myeclipse,打开数据库视图,对应的是Win ...
- 紫书 习题 8-2 UVa 1610 (暴力出奇迹)
这道题我真的想的非常的复杂, 拿草稿纸一直在找规律,推公式, 然后总有一些特殊的情况. 然后就WA了N次.无奈之下看了别人的博客, 然后就惊了.直接暴力枚举两个相邻字符串 里面的所有可能就可以了--真 ...