Sum Problem's Link:   http://acm.hdu.edu.cn/showproblem.php?pid=4704 Mean: 给定一个大整数N,求1到N中每个数的因式分解个数的总和. analyse: N可达10^100000,只能用数学方法来做. 首先想到的是找规律.通过枚举小数据来找规律,发现其实answer=pow(2,n-1); 分析到这问题就简单了.由于n非常大,所以这里要用到费马小定理:a^n ≡ a^(n%(m-1)) * a^(m-1)≡ a^(n%(m-…
题意 : 给出数 x (1 ≤ x ≤ 10^12 ),要求求出所有满足 1 ≤ n ≤ x 的 n 有多少个是满足 n*a^n  = b ( mod p ) 分析 : 首先 x 的范围太大了,所以使用枚举进行答案的查找是行不通的 观察给出的同余恒等式,发现这个次方数 n 毫无规律 自然想到化成费马小定理的形式 令 n = i*(p-1)+j 式子化成 根据费马小定理不难证明(猜???)周期为 p*(p-1) ==> 来自 Tutorial,反正我是不知道怎么证,貌似评论下面有大神用欧拉函数来证…
Description Consider a positive integer X,and let S be the sum of all positive integer divisors of 2004^X. Your job is to determine S modulo 29 (the rest of the division of S by 29). Take X = 1 for an example. The positive integer divisors of 2004^1…
What day is that day? Time Limit: 2 Seconds      Memory Limit: 65536 KB It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days? Input There are multiple test cases. The first line of input contains an integer T indicating the number o…
POJ 1845 题意不说了,网上一大堆.此题做了一天,必须要整理一下了. 刚开始用费马小定理做,WA.(poj敢说我代码WA???)(以下代码其实都不严谨,按照数据要求A是可以等于0的,那么结果自然就是0了,需要特判一下,但是poj好像没有为0的数据,能AC.先不改了.) 后来看了好多人的博客,发现很少用费马小定理写的,或者写的代码我看不下去..就先用那个什么二分等比数列写了一下. 过程也不说了,很多博客都说了.([1][2]): #include<iostream> #include<…
Ignatius's puzzle Problem Description Ignatius is poor at math,he falls across a puzzle problem,so he has no choice but to appeal to Eddy. this problem describes that:f(x)=5x13+13*x5+ka*x,input a nonegative integer k(k<10000),to find the minimal none…
题意:求奇质数 P 的原根个数.若 x 是 P 的原根,那么 x^k (k=1~p-1) 模 P 为1~p-1,且互不相同. (3≤ P<65536) 解法:有费马小定理:若 p 是质数,x^(p-1)=1 (mod p).这和求原根有一定联系. 再顺便提一下欧拉定理:若 a,n 互质,那么 a^Φ(n)=1(mod n).    还有一个推论:若x = y(mod φ(n) 且 a与n 互质,则有 a^x=a^y(mod n). 百度百科是这么说的:"原根,归根到底就是 x^(p-1)=…
Description 题目描述 It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days? 今天是星期六,11 + 22 + 33 + ... + NN 天后是星期几? Input 输入 There are multiple test cases. The first line of input contains an integer T indicating the number of test cases.…
斐蜀定理 内容 斐蜀定理又叫贝祖定理,它的内容是这样的: 若$a,bin N$,那么对于任意x,y,方程$ax+by=gcd(a,b)*k(kin N)$一定有解,且一定有一组解使$ax+by=gcd(a,b)$ 推论 a,b互素的充要条件是方程$ax+by=1$有整数解. 证明 令$d=gcd(a,b)$,则$d|a,d|b$ 那么就能得到$d|(ax+by)$ 于是我们设s为$ax+by$能得到的最小正整数值,则$d|s$. 令$q=adiv s$(此处为整除),$r=amod s$,则$a…
What day is that day? Time Limit: 2 Seconds Memory Limit: 65536 KB It's Saturday today, what day is it after 11+22+33+...+NN1^1 + 2^2 + 3^3 + ... + N^N11+22+33+...+NN days? Input There are multiple test cases. The first line of input contains an inte…