hdu 1212 Big Number(大数取模)
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.
12 7
152455856554521 3250
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(大数取模)的更多相关文章
- HDU 1212 大整数的取模运算
因为这里是MOD最大为100000 所以我将字符串看作5个一组,并记录后面跟了多少个100000 每次取5个数根据其数据进行取模更新 注意过程中 100000*100000会超int #include ...
- HDU 1212 Big Number 大数模小数
http://acm.hdu.edu.cn/showproblem.php?pid=1212 题目大意: 给你一个长度不超过1000的大数A,还有一个不超过100000的B,让你快速求A % B. 什 ...
- 题解报告:hdu 1212 Big Number(大数取模+同余定理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1212 Problem Description As we know, Big Number is al ...
- hdu2302(枚举,大数取模)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2303 题意:给出两个数k, l(4<= k <= 1e100, 2<=l<=1 ...
- (POJ2635)The Embarrassed Cryptographer(大数取模)
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13041 Accep ...
- 【大数取模】HDOJ-1134、CODEUP-1086
1086: 大数取模 题目描述 现给你两个正整数A和B,请你计算A mod B.为了使问题简单,保证B小于100000. 输入 输入包含多组测试数据.每行输入包含两个正整数A和B.A的长度不超过1 ...
- HDU4704Sum 费马小定理+大数取模
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4704 题目大意: 看似复杂,其实就是求整数n的划分数,4=1+1+2和4=1+2+1是不同的.因而可 ...
- HDU--1212大数取模
大数取模问题.题目传送门:HDU1212 #include <iostream> using namespace std; char a[1010]; int main() { int b ...
- 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个东西中间插任意个板子 ...
- HPU 1471:又是斐波那契数列??(大数取模)
1471: 又是斐波那契数列?? 时间限制: 1 Sec 内存限制: 128 MB 提交: 278 解决: 27 统计 题目描述 大家都知道斐波那契数列吧?斐波那契数列的定义是这样的: f0 = 0; ...
随机推荐
- HDU2639[背包第K大]
题目链接[http://acm.hdu.edu.cn/showproblem.php?pid=2639] 题意:求第k大背包. 题解:利用二路归并的思想,求解第K大的值. #include<bi ...
- Learning C# by Developing Games with Unity 5.x(2nd)
项目:https://pan.baidu.com/s/1o7IMcZo using UnityEngine; using System.Collections; namespace VoidGame ...
- maven 阿里镜像
<mirror> <id>alimaven</id> <mirrorOf>central</mirrorOf> <name>al ...
- iOS开发工具箱
工欲善其事 必先利其器 最新重新安装了MacBook Air和Mac Pro的系统,彻底解决了一编译就报硬盘空间不足的问题.平时开发中比较常用的工具都需一一安装. XCode:没什么好说的,外星人都知 ...
- linux下安装nginx+php
参考:http://blog.csdn.net/ihelloworld/article/details/7029796 http://blog.chinaunix.net/uid-21374062-i ...
- HomeBrew 安装 PHP7.1(开发笔记)
HomeBrew 安装 PHP7.1 $ brew update $ brew tap homebrew/dupes $ brew tap homebrew/php $ brew update $ b ...
- 对jquery新增加的class绑定事件
当页面加载时,就会注册所有的事件,后面通过jquery新增的内容(<div class="item"></div>),再对新增的添加事件$(".i ...
- iOS开发QQ空间半透明效果的实现
//1.首先我们可以确定的是cell的半透明, /* white The grayscale value of the color object, specified as a value from ...
- hdu_5961_传递(bitset)
题目链接:hdu_5961_传递 题意: 中文,不解释 题解: 上bitset卡常,很优美的就过去了 #include<bits/stdc++.h> #define F(i,a,b) fo ...
- LeetCode OJ 42. Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, comput ...