摘要:
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6608 题目大意: 给定一个素数p,找到比p小的最大素数q,计算q! mod p 解题思路: 这道题有三种方法 第一种(最快): 先用Miller_Rabin测试找到q,根据威尔逊定理,(p-1)! mo 阅读全文
摘要:
威尔逊定理:若p为素数,则p可以整除(p-1)!+1 例题1:hdu5391 直接套用威尔逊定理,注意n=4的结果是2 代码: #include<bits/stdc++.h> #define ll long long using namespace std; const int N = 1e9+39 阅读全文
摘要:
1.付钱 题目链接:https://www.luogu.com.cn/problem/U303904 代码: #include<bits/stdc++.h> #define ll long long using namespace std; int main(){ ll n;cin>>n; cout 阅读全文
摘要:
1.珠心算测验 代码: #include<bits/stdc++.h> #define ll long long using namespace std; const int N = 2e4+39+7; int mp[N],n,a[N],ans=0; int main(){ cin>>n; for( 阅读全文
摘要:
1.金币 代码: #include<bits/stdc++.h> #define ll long long using namespace std; int ans=0,t=1,n; int main(){ cin>>n; while(n){ for(int i=1;i<=t;i++){ ans+= 阅读全文