http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #include<cstring> #include<algorithm> using namespace std; typedef long long ll; int jc[100003]; int p; int ipow(int x, int b) { ll t = 1, w = x;…
Codeforces Round #258 (Div. 2) Devu and Flowers E. Devu and Flowers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Devu wants to decorate his garden with flowers. He has purchased n boxes…
Unknown Treasure Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2389 Accepted Submission(s): 885 Problem Description On the way to the next secret treasure hiding place, the mathematician…
Unknown Treasure Time Limit: 1500/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2209 Accepted Submission(s): 821 Problem Description On the way to the next secret treasure hiding place, the mathematician…
Saving Beans Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4315 Accepted Submission(s): 1687 Problem Description Although winter is far away, squirrels have to work day and night to save be…
Lucas' theorem In number theory, Lucas's theorem expresses the remainder of division of the binomial coefficient by a prime number p in terms of the base p expansions of the integers m and n. ----wiki 表达式 对于非负整数m.n和素数p,如果有: 则有下式成立: 牛刀小试 题目链接:hdu-…
The figure below shows Pascal's Triangle: Baby H divides Pascal's Triangle into some Diagonals, like the following figure: Baby H wants to know the sum of K number in front on the Mth diagonal. Try to calculate it. Input There are multiple test cases…
对于C(n, m) mod p.这里的n,m,p(p为素数)都很大的情况.就不能再用C(n, m) = C(n - 1,m) + C(n - 1, m - 1)的公式递推了. 这里用到Lusac定理 For non-negative integers m and n and a prime p, the following congruence relation holds: where and are the base p expansions of m and n respectively.…
Xiao Ming's Hope Time Limit:1000MS Memory Limit:32768KB Description Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to show he is alone without a girl friend. The day…
Problem Description Although winter is far away, squirrels have to work day and night to save beans. They need plenty of food to get through those long cold days. After some time the squirrel family thinks that they have to solve a problem. They supp…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5446 Unknown Treasure 问题描述 On the way to the next secret treasure hiding place, the mathematician discovered a cave unknown to the map. The mathematician entered the cave because it is there. Somewhere…
原来一张图就就能证明:C(N,M)%P,p是素数. 简直太炫酷 先膜拜会 #include<iostream>#include<cstdio>#include<ctime>#include<cstring>#include<cstdlib>#include<vector>#define C 240#define TIME 10#define LL long longusing namespace std;LL PowMod(LL a,…