摘要: 欧拉函数的原式是φ(n)=Σ[gcd(i,n)=1],它是一种积性函数,他符合:设p,q是互素的正整数,φ(pq)=φ(p)φ(q) 欧拉函数定理1:设p,q是互素的正整数,φ(pq)=φ(p)φ(q) 欧拉函数定理2:n=Σφ(d) 欧拉函数定理3:φ(n)=nΠ(1-1/pi) 他最早应用在密码 阅读全文
posted @ 2023-07-07 20:58 天雷小兔 阅读(142) 评论(0) 推荐(0)
摘要: 积性函数的定义:如果算数函数f对于任意两个素数p,q均有f(pq)=f(p)f(q),那么称算数函数f为积性函数 在狄利克雷卷积中较常见的几种函数: 1.单位函数 id(n)=n 2.幂函数 Ik(n)=nk 3.元函数 ε(n)=(n==1?1:0) 4.因数和函数 σ(n)=sum(d)(n/d 阅读全文
posted @ 2023-07-06 20:07 天雷小兔 阅读(98) 评论(0) 推荐(0)
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6608 题目大意: 给定一个素数p,找到比p小的最大素数q,计算q! mod p 解题思路: 这道题有三种方法 第一种(最快): 先用Miller_Rabin测试找到q,根据威尔逊定理,(p-1)! mo 阅读全文
posted @ 2023-07-05 21:46 天雷小兔 阅读(37) 评论(0) 推荐(0)
摘要: 威尔逊定理:若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 阅读全文
posted @ 2023-07-05 21:35 天雷小兔 阅读(50) 评论(0) 推荐(0)
摘要: 素数判定方法 方法一:试除法 从2到sqrt(n),依次试除 代码: #include<bits/stdc++.h> #define ll long long using namespace std; bool isPrime(ll n){ if(n<2)return 0; for(int i=2; 阅读全文
posted @ 2023-07-04 17:20 天雷小兔 阅读(57) 评论(0) 推荐(0)
摘要: 求逆 例题1:P1082 [NOIP2012 提高组] 同余方程 模板题,使用拓展欧几里得算法求逆 代码: #include<bits/stdc++.h> #define ll long long using namespace std; ll gcd(ll a,ll b,ll &x,ll &y){ 阅读全文
posted @ 2023-07-03 16:59 天雷小兔 阅读(50) 评论(0) 推荐(0)
摘要: 方程ax+by=c被称为二元线性丢番图方程 二元线性丢番图方程例题:洛谷P1516 使用拓展欧几里得算法求解x 注意:本题的拓展欧几里得算法函数需要是正数 代码: #include<bits/stdc++.h> #define ll long long using namespace std; ll 阅读全文
posted @ 2023-07-02 20:16 天雷小兔 阅读(74) 评论(0) 推荐(0)
摘要: 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 阅读全文
posted @ 2023-06-03 21:08 天雷小兔 阅读(308) 评论(0) 推荐(0)
摘要: 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( 阅读全文
posted @ 2023-05-24 21:11 天雷小兔 阅读(44) 评论(0) 推荐(0)
摘要: 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+= 阅读全文
posted @ 2023-05-23 10:13 天雷小兔 阅读(90) 评论(0) 推荐(0)