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-Active Direcotry编程示例
查找指定的AD帐号 using (DirectoryEntry de = new DirectoryEntry("LDAP://RootDSE")) { string DCName ...
- WinServer-IIS-FTP服务器
在设置FTP服务器的时候,注意SSL的设置,简单尝试的话,不需要启用SSL 常用FTP命令 ftp 进入FTP命令模式 open 192.168.10.6 (连接到FTP主机,或者open ...
- 【源代码】将一个整数的每位数分解并按逆序放入一个数组中(用递归算法)(C语言实现)
帮朋友做的,好像是一个面试题.假设不过考察递归的话.应该是够了,程序的健壮性和通用性都非常一般的说-- #include <stdio.h> #include <stdlib.h&g ...
- 游标和动态SQL
游标类别:静态游标(指在编译的时候,游标就与一个select语句进行了静态绑定的游标.这样的游标仅仅能作用于一个查询语句)和动态游标(就是希望我们的查询语句在执行的时候才跟游标绑定.为了使用动态游标, ...
- Flutter 1.5 发布,正式成为全平台 UI 框架!
一. 序 在 Google I/O 2019 上,Dart 团队宣布推出新的 Flutter 稳定版本 1.5,这是 Flutter 迄今为止最大的一次版本发布. 伴随着 Flutter 1.5 的发 ...
- bzoj1305: [CQOI2009]dance跳舞(二分答案+网络流)
1305: [CQOI2009]dance跳舞 题目:传送门 题解: 一眼网络流基础建模...然后就GG了 二分答案+拆点建边+最大流判断: 把男女生拆为男1,男2,女1,女2 1.男1和男2还有女1 ...
- 修改echarts环形图的牵引线及文字位置
修改echarts环形图的牵引线及文字位置,下面代码及效果不仅如此,也包含了其它的效果哦.有问题可以留言. 根据echarts官方示例修改效果: 官方示例图: 修改效果图: 直接上代码:其它不多说. ...
- winform控件命名规范对照表
WinForm Control 命名规范 数据类型 数据类型简写 标准命名举例 Label lbl lblMessage LinkLabel llbl llblToday Button btn btn ...
- Win7 利用批处理文件结束进程
@echo offtitle 结束进程正在进行... ::结束进程TeamViewer.exewmic process where name="TeamViewer.exe" ca ...
- KMP算法中求next数组的实质
在串匹配模式中,KMP算法较蛮力法是高效的算法,我觉得其中最重要的一点就是求next数组: 看了很多资料才弄明白求next数组是怎么求的,我发现我的忘性真的比记性大很多,每次看到KMP算法求next数 ...