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很大,那我 ...
随机推荐
- mySql---or和in的效率问题(和<=、>=、between之间的关系)
写在前面: 本文是直接拿取的别人的实验数据作参考,然后对数据作分析. 参考网友的测试数据结果: 在网上一直看到的是or和in的效率没啥区别,一直也感觉是这样,前几天刚好在看<mysql数据库开发 ...
- Tomcat篇
安装tomcat 先从tomcat官网找到最新的版本下载地址,我找的是Core下的安装包,下载到本地: wget http://mirror.bit.edu.cn/apache/tomcat/tomc ...
- WinPE作为启动硬盘
之前我一直是用UltraISO将U盘制作为启动盘,这种方式本身简单易用,但也有一些令人不爽的地方 每次都要重新格式化U盘, 本身WinPE并不大,只需要几百兆空间,一旦U盘在使用时,明明都有足够的空间 ...
- linux系统时间同步,硬件时钟和系统时间同步,时区的设置
1.时间同步(手动): date -s "2015-07-15 22:13:30" hwclock --systohc (表示系统时间同步到硬件时钟) hwclo ...
- 给Android组件添加事件一个很好用的方法
在这里想和大家分享一下很好用的添加事件方法,特别是在处理ListView里的Item事件的时候,很方便. 首先,在XML里布局的时候,添加这样一个属性: android:onClick="C ...
- Android native层动态库注射
1.简单介绍 本文解说在Android native层.root权限下.注射动态库到目标进程,从而hook目标进程中动态库的函数的实现方式. 文中的源代码所有来源于网络.我仅仅是略微加以整理. 环境: ...
- IOS学习笔记41--图片的缩放(一)
图片的缩放 一:Pinch手势对图片进行缩放.即用两根手指往不同方向拖拉照片,照片会被缩小或放大. 我理解的原理:等比缩放 先看如下关键代码: 1.初始化参数 - (void)viewDidLoad ...
- Apache Mina入门
Mina第一次听到这个名称的时候,我以为是个MM的名字米娜,后来才知道… Apache MINA(Multipurpose Infrastructure for Network Application ...
- 高手写的“iOS 的多核编程和内存管理”
原文地址:http://anxonli.iteye.com/blog/1097777 多核运算 在iOS中concurrency编程的框架就是GCD(Grand Central Dispatch), ...
- [翻译] AGPhotoBrowser 好用的图片浏览器
AGPhotoBrowser 好用的图片浏览器 https://github.com/andreagiavatto/AGPhotoBrowser A photo browser for iOS6 a ...