Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 16244 Accepted: 4044 Description Consider two natural numbers A and B. Let S be the sum of all natural divisors of A^B. Determine S modulo 9901 (the rest of the division of S by 9901).…
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34985 We define a kind of strings as elegant string: among all the substrings of an elegant string, none of them is a permutation of "0, 1,…, k". Let function(n, k) be the number of elegant s…
转载请注明出处:http://www.cnblogs.com/KirisameMarisa/p/4187670.html 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3306 Another kind of Fibonacci Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1720 …
关于快速幂这个算法,已经不想多说,很早也就会了这个算法,但是原来一直靠着模板云里雾里的,最近重新学习,发现忽视了一个重要的问题,就是若取模的数大于int型,即若为__int64的时候应该怎么办,这样就得用到乘法快速幂+乘方快速幂了. 快速幂一般是为了解决乘方取模问题的,显然思想就是二分,下面贴上快速幂模板: __int64 mulpow(__int64 a,__int64 p,__int64 m) { __int64 ans = ; while(p) { ) ans = ans * a % m;…
Luogu T7152 细胞(递推,矩阵乘法,快速幂) Description 小 X 在上完生物课后对细胞的分裂产生了浓厚的兴趣.于是他决定做实验并 观察细胞分裂的规律. 他选取了一种特别的细胞,每天每个该细胞可以分裂出 x − 1 个新的细胞. 小 X 决定第 i 天向培养皿中加入 i 个细胞(在实验开始前培养皿中无细胞). 现在他想知道第 n 天培养皿中总共会有多少个细胞. 由于细胞总数可能很多,你只要告诉他总数对 w 取模的值即可. Input 第一行三个正整数 n, x,w Outpu…
#include<cstdio> int power(int a, int b, int p) { %p; ) { ) ans=(long long)ans*a%p; a=(long long)a*a%p; } return ans; } int main() { int a,b,c; scanf("%d%d%d", &a, &b, &c); printf("%d^%d mod %d=%d", a,b,c,power(a,b,c)…
Sequence Problem Description Let us define a sequence as below f1=A f2=B fn=C*fn-2+D*fn-1+[p/n] Your job is simple, for each task, you should output Fn module 109+7. Input The first line has only one integer T, indicates the number of tasks. Then,…
A thief made his way to a shop. As usual he has his lucky knapsack with him. The knapsack can contain k objects. There are n kinds of products in the shop and an infinite number of products of each kind. The cost of one product of kind i is ai. The t…
Sumdiv Time Limit:1000MS Memory Limit:30000KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1845 Appoint description: System Crawler (2015-05-27) Description Consider two natural numbers A and B. Let S be the sum of all natural…
薛先生想改变后代的IQ,为此他发明了一种药,这种药有三种属性:A, B,P.他父亲的智商为X,薛先生的智商为Y,用了这种药之后,薛先生的孩子的智商就可以变为(AX+BY) mod P.后代的智商以此类推. 现在给定X和Y,还有药的属性A.B和P,现在他想知道他的N代子孙的IQ(儿子是第一代,孙子是第二代). Input第一行包含一个整数T(T<=100),表示数据组数 每组数据只有一行,包含六个整数X,Y,A,B,P,N(1 ≤ X, Y ≤ 300,1 ≤ A, B ≤ 30, 1≤ P ≤…
题目链接:http://poj.org/problem?id=3233 Description Given a n × n matrix A and a positive integer k, find the sum S = A + A2 + A3 + … + Ak. Input The input contains exactly one test case. The first line of input contains three positive integers n (n ≤ 30…