Big Number

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 6015 Accepted Submission(s): 4205

Problem Description
As we know, Big Number is always troublesome. But it's really important in our ACM. And today, your task is to write a program to calculate A mod B.



To make the problem easier, I promise that B will be smaller than 100000.



Is it too hard?

No, I work it out in 10 minutes, and my program contains less than 25 lines.

Input
The input contains several test cases. Each test case consists of two positive integers A and B. The length of A will not exceed 1000, and B will be smaller than 100000. Process to the end of file.
Output
For each test case, you have to ouput the result of A mod B.
Sample Input
2 3
12 7
152455856554521 3250
Sample Output
2
5
1521
Author
Ignatius.L
Source
Recommend
Eddy | We have carefully selected several similar problems for you:
1215 1211 1210 1214

pid=1695" target="_blank">
1695


#include<stdio.h>
#include<string.h>
int main(){
int b;
char a[1010];
while(~scanf("%s%d",a,&b)){
int len=strlen(a),res=0;
for(int i=0;i<len;++i){
res=res*10+a[i]-'0';
if(res>=b)
res=res%b;
}
printf("%d\n",res);
}
return 0;
}


hdoj-1212-Big Number【大数取余&amp;简单题】的更多相关文章

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

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

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

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

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

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

  4. java大数取余

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

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

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

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

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

  7. HDU - 4704 sum 大数取余+欧拉降幂

    Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submi ...

  8. 2016中国大学生程序设计竞赛 - 网络选拔赛 1001 A water problem (大数取余)

    Problem Descripton Two planets named Haha and Xixi in the universe and they were created with the un ...

  9. hdu1226 超级密码 (BFS,里面用了大数取余原理)

    Problem Description Ignatius花了一个星期的时间终于找到了传说中的宝藏,宝藏被放在一个房间里,房间的门用密码锁起来了,在门旁边的墙上有一些关于密码的提示信息: 密码是一个C进 ...

随机推荐

  1. S5PV210 三个Camera Interface/CAMIF/FIMC的区别

    S5PV210有三个CAMIF单元,分别为CAMIF0 CAMIF1和CAMIF2.对应着驱动中的fimc0, fimc1, fimc2.在三星datasheet和驱动代码中CAMIF和FIMC(Fu ...

  2. oracle 的交并差函数,intersect;union;minus。

    创建表并添加数据: --创建TABLE_A create table TABLE_A ( A ), B ) ); --给TABLE_A添加数据 insert into TABLE_A values(' ...

  3. hive的mysql作元数据的hive-site.xml配置

    <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://s ...

  4. css所有属性(table,行列组)总结

    概述: CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明: CSS声明总是以分号(;)结束,声明组以大括号({})括起来: 一.注释: CSS注释以 "/*" 开始, ...

  5. 【【henuacm2016级暑期训练】动态规划专题 L】Civilization

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 给一个森林. 就是由很多棵树组成.. 然后会询问你其中一棵树的最长链. 初始状态的最长链可以用两遍dfs分别找最长路得到. 然后要求 ...

  6. ASP.NET-Microsoft.Management.Infrastructure错误

    错误如图所示,将MVC发布到IIS上就会出现这个错误,我用到了NPOI这个EXCEL插件,不知道是不是这个造成的,但是实在找不到解决方案,就直接将BIN目录下的这个Microsoft.Manageme ...

  7. [Oracle] Merge语句

    Merge的语法例如以下: MERGE [hint] INTO [schema .] table [t_alias] USING [schema .] { table | view | subquer ...

  8. JDBC连接mysql增删改查整体代码

    第一种比较low:用了statment,没有用preparedstatement.另外,插入时,不灵活,不能调用参数,但是如果直接给函数形参的话就会被SQL注入攻击,所以,最好在sql语句中使用?代表 ...

  9. 三种SVM的对偶问题

    一.SVM原问题及要变成对偶问题的解决办法 对于SVM的,我们知道其终于目的是求取一分类超平面,然后将新的数据带入这一分类超平面的方程中,推断输出结果的符号,从而推断新的数据的正负. 而求解svm分类 ...

  10. @dynamic与@synthesize的差别

    如今非常多时候我们都已经不再使用@synthesizekeyword了,可是须要了解当中的原理: 一.@dynamic与@synthesize的差别 @property有两个相应的词.一个是@synt ...