http://lightoj.com/volume_showproblem.php?problem=1214

这就是一道简单的大数取余。

还想还用到了同余定理:

所谓的同余,顾名思义,就是许多的数被一个数d去除,有相同的余数。d数学上的称谓为模。如a=6,b=1,d=5,则我们说a和b是模d同余的。因为他们都有相同的余数1。

////

数学上的记法为:
a≡ b(mod d)
可以看出当n<d的时候,所有的n都对d同商,比如时钟上的小时数,都小于12,所以小时数都是模12的同商.
对于同余有三种说法都是等价的,分别为:
(1) a和b是模d同余的.
(2) 存在某个整数n,使得a=b+nd .
(3) d整除a-b.
可以通过换算得出上面三个说法都是正确而且是等价的.
 
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue> using namespace std;
typedef long long LL;
#define N 100000
#define ESP 1e-8
#define INF 0x3f3f3f3f
#define memset(a,b) memset(a,b,sizeof(a)) int main()
{
int T, t=;
scanf("%d", &T);
while(T --)
{
char s[];
LL b;
scanf("%s %lld", s, &b);
if(b < )
b = -b; printf("Case %d: ", t++); int len = strlen(s);
if(len == && s[] == '')
{
printf("divisible\n");
continue;
} LL sum = ;
for(int i=; i<len; i++)
{
if(s[i] == '-')
continue; sum = sum* + s[i]-'';
sum = sum%b;
} if(sum == )
printf("divisible\n");
else
printf("not divisible\n");
}
return ;
}

1214 - Large Division -- LightOj(大数取余)的更多相关文章

  1. lightoj--1214--Large Division(大数取余)

    Large Division Time Limit: 1000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Submit ...

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

  3. light oj 1214 - Large Division

    1214 - Large Division   PDF (English) Statistics Forum Time Limit: 1 second(s) Memory Limit: 32 MB G ...

  4. POJ2635The Embarrassed Cryptographer(大数取余+素数筛选+好题)

    题目链接 题意:K是由两个素数乘积,如果最小的素数小于L,输出BAD最小的素数,否则输出GOOD 分析 素数打表将 L 大点的素数打出来,一定要比L大,然后就开始枚举,只需K对 素数 取余 看看是否为 ...

  5. java大数取余

    java大数取余: 类方法:BigInteger.divideAndRemainder() 返回一个数组,key = 0为商key = 1为余数 import java.util.*; import ...

  6. hdu 1226 bfs+余数判重+大数取余

    题目: 超级密码 Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  7. Codeforces Round #279 (Div. 2) C. Hacking Cypher (大数取余)

    题目链接 C. Hacking Cyphertime limit per test1 secondmemory limit per test256 megabytesinputstandard inp ...

  8. 2019计蒜之道初赛3 D. 阿里巴巴协助征战SARS(困难)(大数取余+欧拉降幂)

    阿里巴巴协助征战SARS(困难) 33.29% 1000ms 262144K   目前,SARS 病毒的研究在世界范围内进行,经科学家研究发现,该病毒及其变种的 DNA 的一条单链中,胞嘧啶.腺嘧啶均 ...

  9. LightOJ 1214 Large Division

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

随机推荐

  1. OpenGL 矩阵变换

    Overview 几何数据--顶点位置,和标准向量(normal vectors),在OpenGL 管道raterization 处理过程之前可通过顶点操作(Vertex Operation)和基本组 ...

  2. 用EasyWebSvr搭建Axure本地访问地址-转载加完善

    1.下载之后解压到任意一个位置,可以是桌面(反正很小不占空间),如图2:: 图2 解压之后文件目录 2.将生成的原型放在EasyWebSvr根目录下的demo之中,如图3所示: 图3  原型文件放置目 ...

  3. ipython的安装

    ipython:是python的一个交互式shell环境,可以安装到windows和linux上面.作用:用来执行python代码和调试用.windows上面安装:分为2.x版本和3.x版本,分为py ...

  4. TextVeiw 的 No package identifier when getting value for resource numb

    tv_title,tv_detail,tv_comment都是TextView; newInfo.getComment()得到的是int类型 tv_title.setText(newInfo.getT ...

  5. mac 查看无线wifi的密码

    finder->应用程序->实用工具->钥匙串访问->右上角输入wifi名查找->显示密码(需要管理员账号)

  6. dma_ops

    kernel中的dma缓存区管理层操作统一实现在  struct dma_map_ops 中: dma缓存区分配函数的具体实现参考: http://www.aichengxu.com/view/599 ...

  7. java.net.SocketException: No buffer space available (maximum connections reached?): JVM_Bind

    1. 启动注册表编辑器. HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/Tcpip/Parameters 2. 新建 值名称:MaxUser ...

  8. Action名称的搜索顺序

    假设当前的路径的URL是:http://StrutsDemo01/path1/path2/path3/test.action 步骤1.首先寻找命名空间(namespace)为 /path1/path2 ...

  9. modelsim无法识别include文件的解决方法

    modelsim发现include关联的文件编译报语法错误,文件名需要写绝对路径,即使这个文件和工程其它文件在一个目录上.例如只写成 `include "c0_ddr3_model_para ...

  10. AD账号创建日期、最近一次登录时间、最近一次重置密码时间查询

    一:查询此AD域内所有用户的创建日期 Get-ADuser  -filter * -Properties * | Select-Object Name,SID, Created,PasswordLas ...