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很大,那我 ...
随机推荐
- 基于RBGD的mapping
最近学习RGBD的SLAM,收集了两个RGBD的mapping的开源工具包 1.RGBDSlam2 a.安装方法: #准备工作空间 source /opt/ros/indigo/setup.bash ...
- SpringMVC 方法参数设置
/** 在方法中配置参数: (1) 内置对象配置: request:获取cookie.请求头... 获取项目根路径 request.getContextPath() response:用于ajax的输 ...
- windows的磁盘操作之九——区分本地磁盘与移动硬盘
http://cutebunny.blog.51cto.com/301216/674443 最近碰到了个新问题,记录下来作为windows的磁盘操作那个系列的续篇吧. 一些时候我们的程序需要区分本地存 ...
- HDU1518 Square 【剪枝】
Square Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Su ...
- 23LINQ运算符返回其它类型实例汇总
IEnumerable<T>返回其它集合类型 ToArray() ToList() ToDictionary() ToLookUp() 返回集合中的元素 □ ElementAt ...
- JAVA基础知识要点
MQ.dubbo.SpringCloud 1) 集合框架 2)线程 3)IO流 4)类和对象生命周期 5)JAVA的反射机制 6) JVM 7)数据结构和常用算法 8)设计模式 9)网络编程
- Java Web开发基础(2)-JSP
上一篇博我粗略的介绍了一下Servlet.粗略是由于博主也刚刚学习这部分的内容,还不是非常懂所以无法讲的非常精细.可是本着二八原则,我还是先继续学习.所以,这篇博客接着JSP的内容.由于.这两个内容关 ...
- 文件权限控制篇access alphasort chdir chmod chown chroot closedir fchdir fchmod fchown fstat ftruncate getcwd
access(判断是否具有存取文件的权限) 相关函数 stat,open,chmod,chown,setuid,setgid 表头文件 #include<unistd.h> 定义函数 in ...
- ldap服务器OpenLDAP安装使用
OpenLDAP 是 LDAP 协议的一个开源实现.LDAP 服务器本质上是一个为只读访问而优化的非关系型数据库.它主要用做地址簿查询(如 email 客户端)或对各种服务访问做后台认证以及用户数据权 ...
- mybatis查询时间段sql语句
转载自:http://blog.csdn.net/zl544434558/article/details/24428307?utm_source=tuicool&utm_medium=refe ...