Fansblog 题目传送门 解题思路 Q! % P = (P-1)!/(P-1)...(Q-1) % P. 因为P是质数,根据威尔逊定理,(P-1)!%P=P-1.所以答案就是(P-1)((P-1)...*(Q-1)的逆元)%P.数据很大,用__int128. 代码如下 #include <bits/stdc++.h> #define INF 0x3f3f3f3f using namespace std; typedef long long ll; inline int read(){ in…
Fansblog Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3170 Accepted Submission(s): 671 Problem Description Farmer John keeps a website called 'FansBlog' .Everyday , there are many people visite…
参考博客:https://blog.csdn.net/birdmanqin/article/details/97750844 题目链接:链接:http://acm.hdu.edu.cn/showproblem.php?pid=6608 威尔逊定理:在初等数论中,威尔逊定理给出了判定一个自然数是否为素数的充分必要条件.即:当且仅当p为素数时:( p -1 )! ≡ -1 ( mod p ),但是由于阶乘是呈爆炸增长的,其结论对于实际操作意义不大. 题意:T组样例.每组样例,给出一个素数P(1e…
<题目链接> Zball in Tina Town Problem Description Tina Town is a friendly place. People there care about each other.Tina has a ball called zball. Zball is magic. It grows larger every day. On the first day, it becomes 1 time as large as its original siz…
The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, they decided to put Yet-Another-Public-Turing-Test-to-Tell-Computers-and-Humans-Apart on their webpag…
YAPTCHA Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1885 Accepted Submission(s): 971 Problem Description The math department has been having problems lately. Due to immense amount of u…
题意:给定质数p,求q!模p的值,其中q为小于p的最大质数 1e9<=p<=1e14 思路:根据质数密度近似分布可以暴力找q并检查 找到q后根据威尔逊定理: 把q+1到p-1这一段的逆元移过去 #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int,…
Problem Description Farmer John keeps a website called ‘FansBlog’ .Everyday , there are many people visited this blog.One day, he find the visits has reached P , which is a prime number.He thinks it is a interesting fact.And he remembers that the vis…
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 219 Accepted Submission(s): 144 Problem Description Tina Town i…
YAPTCHA Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 875 Accepted Submission(s): 458 Problem Description The math department has been having problems lately. Due to immense amount of uns…
<题目链接> 题目大意: The task that is presented to anyone visiting the start page of the math department is as follows: given a natural n, compute where [x] denotes the largest integer not greater than x. 给出 t 和n,t代表样例组数,根据给出的n算出上面表达式.(注意:[x]表示,不超过x的最大整数)…
YAPTCHA Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1490 Accepted Submission(s): 811 Problem Description The math department has been having problems lately. Due to immense amount of uns…
参考博客 HDU-2973 题目 Problem Description The math department has been having problems lately. Due to immense amount of unsolicited automated programs which were crawling across their pages, they decided to put Yet-Another-Public-Turing-Test-to-Tell-Compu…
Zball in Tina Town Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 262144/262144 K (Java/Others) Problem Description Tina Town is a friendly place. People there care about each other. Tina has a ball called zball. Zball is magic. It grows lar…
The Designer Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 761 Accepted Submission(s): 142 Problem Description Nowadays, little haha got a problem from his teacher.His teacher wants to desi…
Invoker Time Limit : 2000/1000ms (Java/Other) Memory Limit : 122768/62768K (Java/Other) Total Submission(s) : 1 Accepted Submission(s) : 0 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description On of Vance's favourite hero i…
题意:在杨辉三角中让你从最上面到 第 n 行,第 m 列所经过的元素之和最小,只能斜向下或者直向下走. 析:很容易知道,如果 m 在n的左半部分,那么就先从 (n, m)向左,再直着向上,如果是在右半部分,那么就是先向左斜着走再向上.这样对应到, 然后化简得到的答案就是C(n+1, m) + n - m,和C(n+1, m+1) + m.然后用Lucsa 定理就好. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000"…
Saving Beans Saving Beans Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5761 Accepted Submission(s): 2310 Problem Description Although winter is far away, squirrels have to work day and nig…
Problem Description Farmer John keeps a website called ‘FansBlog’ .Everyday , there are many people visited this blog.One day, he find the visits has reached P , which is a prime number.He thinks it is a interesting fact.And he remembers that the vis…
DP? Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 128000/128000 K (Java/Others)Total Submission(s): 3126 Accepted Submission(s): 978 Problem Description Input Input to the problem will consists of series of up to 100000 data sets. For e…