1243. Divorce of the Seven Dwarfs Time limit: 1.0 second Memory limit: 64 MB After the Snow White with her bridegroom had left the house of the seven dwarfs, their peaceful and prosperous life has come to an end. Each dwarf blames others to be the re…
1243. Divorce of the Seven Dwarfs Time limit: 1.0 secondMemory limit: 64 MB After the Snow White with her bridegroom had left the house of the seven dwarfs, their peaceful and prosperous life has come to an end. Each dwarf blames others to be the rea…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2303 题意:给出两个数k, l(4<= k <= 1e100, 2<=l<=1e6):其中k是两个素数的乘积,问k是否存在严格小于l的因子,若有,输出 BAD 该因子,反之输出GOOD: 思路: 先1e6内素数打表,再枚举一个因子,判断因子用大数取模: 代码: #include <iostream> #include <stdio.h> #include <…
The Embarrassed Cryptographer Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13041 Accepted: 3516 Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of user…
1086: 大数取模   题目描述 现给你两个正整数A和B,请你计算A mod B.为了使问题简单,保证B小于100000. 输入 输入包含多组测试数据.每行输入包含两个正整数A和B.A的长度不超过1000,并且0<B<100000. 输出 对于每一个测试样例,输出A mod B. 样例输入 2 3 12 7 152455856554521 3250 样例输出 2 5 1521 [概念] (a+b)%n =(a%n+b%n)%n (a-b)%n = (a%n-b%n)%n 实话说刚开始我没看懂…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4704 题目大意: 看似复杂,其实就是求整数n的划分数,4=1+1+2和4=1+2+1是不同的.因而可知答案是2n-1. 题目分析: 因为n实在是太大太大了,这可咋办啊?!n<10100000. 做这场的时候没有注意到,也是当时没有看过什么是费马小定理,居然跟模值有关系!mod=1000000007.这个mod有什么特点呢?它是个质数. 费马小定理揭示了:当p是一个素数并且a和p互质时,ap-1 %…
大数取模问题.题目传送门:HDU1212 #include <iostream> using namespace std; char a[1010]; int main() { int b; while (cin >> a>> b) { int flag = 0; for (int i = 0; a[i] != '\0'; i++) flag = ((flag * 10) % b+ (a[i] - '0') %b) % b; cout << flag <…
题意:给你n个东西,叫你把n分成任意段,这样的分法有几种(例如3:1 1 1,1 2,2 1,3 :所以3共有4种),n最多有1e5位,答案取模p = 1e9+7 思路:就是往n个东西中间插任意个板子,所以最多能插n - 1个,所以答案为2^(n - 1) % p.但是n最大有1e5位数,所以要用小费马定理化简. 小费马定理:假如p是质数,且gcd(a,p)=1,那么a (p-1)≡1(mod p) 所以我们只要把n - 1分解为n - 1 = k(p - 1) + m,而2^ k(p - 1)…
1471: 又是斐波那契数列?? 时间限制: 1 Sec 内存限制: 128 MB 提交: 278 解决: 27 统计 题目描述 大家都知道斐波那契数列吧?斐波那契数列的定义是这样的: f0 = 0; f1 = 1; fi = fi-1 + fi-2 现在给你一个数x,聪明的你一定知道这是斐波那契数列中的第几项. (数据保证x一定有对应的项y,且 0 <= y < 1e4) 输入 第一行一个整数T,表示测试组数. 之后的T行,每行一个数x 输出 对于每个测试数据,输出一行表示数x是第几项 样例…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1212 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…