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

//重最高位开始不断取余,简单来说模拟手算

//比如  985%6

//   9%6=3

//  38%6=2

//  25%6=1

//计算完毕

 #include <iostream>

 using namespace std;
char a[];
int b;
int mod(char *a,int b)
{
int ans=;
for(int i=;a[i]!='\0';i++)
ans=(ans*+a[i]-'')%b;
return ans;
}
int main()
{
while(cin>>a>>b)
{
cout<<mod(a,b)<<endl;
}
return ;
}

hdu 1212 Big Number(大数取模)的更多相关文章

  1. HDU 1212 大整数的取模运算

    因为这里是MOD最大为100000 所以我将字符串看作5个一组,并记录后面跟了多少个100000 每次取5个数根据其数据进行取模更新 注意过程中 100000*100000会超int #include ...

  2. HDU 1212 Big Number 大数模小数

    http://acm.hdu.edu.cn/showproblem.php?pid=1212 题目大意: 给你一个长度不超过1000的大数A,还有一个不超过100000的B,让你快速求A % B. 什 ...

  3. 题解报告:hdu 1212 Big Number(大数取模+同余定理)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1212 Problem Description As we know, Big Number is al ...

  4. hdu2302(枚举,大数取模)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2303 题意:给出两个数k, l(4<= k <= 1e100, 2<=l<=1 ...

  5. (POJ2635)The Embarrassed Cryptographer(大数取模)

    The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13041 Accep ...

  6. 【大数取模】HDOJ-1134、CODEUP-1086

    1086: 大数取模   题目描述 现给你两个正整数A和B,请你计算A mod B.为了使问题简单,保证B小于100000. 输入 输入包含多组测试数据.每行输入包含两个正整数A和B.A的长度不超过1 ...

  7. HDU4704Sum 费马小定理+大数取模

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4704 题目大意: 看似复杂,其实就是求整数n的划分数,4=1+1+2和4=1+2+1是不同的.因而可 ...

  8. HDU--1212大数取模

    大数取模问题.题目传送门:HDU1212 #include <iostream> using namespace std; char a[1010]; int main() { int b ...

  9. ACM-ICPC 2018 焦作赛区网络预赛G Give Candies(隔板定理 + 小费马定理 + 大数取模,组合数求和)题解

    题意:给你n个东西,叫你把n分成任意段,这样的分法有几种(例如3:1 1 1,1 2,2 1,3 :所以3共有4种),n最多有1e5位,答案取模p = 1e9+7 思路:就是往n个东西中间插任意个板子 ...

  10. HPU 1471:又是斐波那契数列??(大数取模)

    1471: 又是斐波那契数列?? 时间限制: 1 Sec 内存限制: 128 MB 提交: 278 解决: 27 统计 题目描述 大家都知道斐波那契数列吧?斐波那契数列的定义是这样的: f0 = 0; ...

随机推荐

  1. 大学二三事——那些事(1)

    虽然另外一个队友早上忽然拉肚子没有办法去了,我个阿骚还是决定出发. 本来以为早点过去签到可以躲过李导,没想到在她上班的路上被她撞见.   坐在早上那班发往周至县的客车的时候,天气忽好忽坏.   从周至 ...

  2. log4j2

    转载自 Blog of 天外的星星: http://www.cnblogs.com/leo-lsw/p/log4j2tutorial.html Log4j 2的好处就不和大家说了,如果你搜了2,说明你 ...

  3. Major and minor numbers

    The major nuber is the driver associated with the device, while the minor number is used by the kern ...

  4. Java多线程:线程同步与关键字synchronized

    一.同步的特性1. 不必同步类中所有的方法, 类可以同时拥有同步和非同步方法.2. 如果线程拥有同步和非同步方法, 则非同步方法可以被多个线程自由访问而不受锁的限制. 参见实验1:http://blo ...

  5. 关于 pace 有意思的一篇文章

    http://www.blogjava.net/xingcyx/archive/2006/12/28/90498.html http://blog.sina.com.cn/s/blog_700a8db ...

  6. 注册表中LEGACY残留项的清理技巧

    http://bbs.kafan.cn/thread-889517-1-1.html 注册表中LEGACY残留项的清理技巧 2.Windows Vista系统 Windows XP系统下的修改权限的方 ...

  7. html 超链接(a)详细讲解

    a:link : http://www.cnblogs.com/yangfeng/archive/2009/07/25/1530962.html 超级链接 超级链接是网站中使用比较频繁的HTML元素, ...

  8. scroll、client和offset的区别

    scroll.client和offset的区别:http://www.cnblogs.com/pcd12321/p/4448420.html

  9. Windows系统顽固文件删除方法

    con nul都是windows的设备,默认是不允许删除的,如果你一定要删除,可以按照以下方法进行删除!新建一个记事本输入一下内容(直接复制即可)DEL /F /A /Q \\?\%1 RD /S / ...

  10. LeetCode OJ 11. Container With Most Water

    Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).  ...