HDU1212 Big Number 【同余定理】
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.
2 3
12 7
152455856554521 3250
2
5
1521
用到同余定理:(a+b)%c=(a%c+b%c)%c=(a+b%c)%c; 附:(a*b)%c=(a%c*b%c)%c;
#include <stdio.h>
#define maxn 1002 char str[maxn]; int main()
{
int m, ans, i;
while(scanf("%s%d", str, &m) != EOF){
ans = 0;
for(i = 0; str[i]; ++i){
ans = (ans * 10 + (str[i] - '0') % m) %m;
}
printf("%d\n", ans);
}
return 0;
}
HDU1212 Big Number 【同余定理】的更多相关文章
- 如何运用同余定理求余数【hdoj 1212 Big Number【大数求余数】】
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- 题解报告:hdu 1212 Big Number(大数取模+同余定理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1212 Problem Description As we know, Big Number is al ...
- [ACM] POJ 2635 The Embarrassed Cryptographer (同余定理,素数打表)
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 11978 A ...
- POJ 1465 Multiple (BFS,同余定理)
id=1465">http://poj.org/problem?id=1465 Multiple Time Limit: 1000MS Memory Limit: 32768K T ...
- CodeForces 17D Notepad(同余定理)
D. Notepad time limit per test 2 seconds memory limit per test 64 megabytes input standard input out ...
- LightOJ1214 Large Division 基础数论+同余定理
Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...
- POJ 2635 The Embarrassed Cryptographer (千进制,素数筛,同余定理)
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 15767 A ...
- AtCoder Regular Contest 119 C - ARC Wrecker 2(同余定理+思维)
Problem Statement There are NN buildings along the AtCoder Street, numbered 11 through NN from west ...
- Light oj 1214-Large Division (同余定理)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1214 题意很好懂,同余定理的运用,要是A数被B数整除,那么A%B等于0.而A很大,那我 ...
随机推荐
- Linux性能监控分析命令(三)—iostat命令介绍
性能监控分析的命令包括如下: 1.vmstat 2.sar 3.iostat 4.top 5.free 6.uptime 7.netstat 8.ps 9.strace 10.lsof 命令介绍: i ...
- 读书笔记_Effective_C++_条款三十九:明智而审慎地使用private继承
private继承的意义在于“be implemented in turns of”,这个与上一条款中说的复合模型的第二层含义是相同的,这也意味着通常我们可以在这两种设计方法之间转换,但书上还是更提倡 ...
- newtonsoft动态修改JObject
直接上代码: var data = new { mobile = ", company = ", isTravel = ", invoiceId = ", se ...
- PostgreSQL高可用集群方案收集/主从切换/一主多从(待实践)
对于业内来说,基本都在围绕主从切换的高可用方案: http://www.10tiao.com/html/175/201509/210974337/1.html https://www.jianshu. ...
- GoodSync 同步 对比 备份
单向/双向皆可,针对任何一侧的文件进行处理,两侧文件都进行更新 文件同步 的操作过程是:确保两处或多处包含完全一致.及时更新 的各种文件.当对某一处进行文件添加.更改或删除,则同步操作将对对应的 另一 ...
- mysqld --debug=d:t:i:O:n --user=mysql (源码调试)
--debug=d:t--debug=d:f,main,subr1:F:L:t,20--debug=d,input,output,files:n--debug=d:t:i:O,\\mysqld.tra ...
- [Mysql]MySQL 服务无法启动。
摘要 在官网下载了mysql,版本mysql-5.7.17-winx64,免安装的压缩包,解压后.放在MySql的文件夹中.电脑系统win10 x64. 配置文件 # For advice on ho ...
- MVC中使用AngularJS-01,基本
Angularjs是一个前端的Javascript MVC 库和框架,使前端得到更好的设计.维护和测试.它的核心特性有:MVC.双向数据绑定.指令和语义化标签.模块化工具.依赖注入.HTML模板,以及 ...
- Entityframework:“System.Data.Entity.Internal.AppConfig”的类型初始值设定项引发异常。
<configSections> <!-- For more information on Entity Framework configuration, visit http:// ...
- Spring加载Hibernate 映射的几种方式及区别
LocalSessionFactoryBean有好几个属性用来查找hibernate映射文件: mappingResources.mappingLocations.mappingDirectoryLo ...