
欧拉函数
文章平均质量分 79
even_bao
这个作者很懒,什么都没留下…
展开
-
【Sdoi2008】沙拉公主的困惑
【题目链接】 点击打开链接【算法】 gcd(a,b)=gcd(a mod b, b),又m!|n! 则有ans=(n!/m!)·ϕ(m!) 由ϕ(n)=n(1-1/p1)(1-1/p2)...(1-1/pk) ans=n!(1-1/p1)(1-1/p2)...(1-1/pk) 这里p1......原创 2018-03-23 22:33:37 · 228 阅读 · 0 评论 -
【SDOI2012】 Longgue的问题
【题目链接】 点击打开链接【算法】 gcd(i,n)是n的约数 不妨设gcd(i,n) = d 考虑枚举d和gcd(i,n) = d有多少个 gcd(i,n) = d gcd(i/d,n/d) = 1 因为i<=n,所以i/d<=n/d ...原创 2018-03-20 21:30:25 · 248 阅读 · 0 评论 -
【BZOJ 2818】 GCD
【题目链接】 点击打开链接【算法】 线性筛出不大于N的所有素数,枚举gcd(x,y)(设为p),问题转化为求(x,y)=p的个数 设x=x'p, y=y'p,那么有(x,y)=1且1≤x,y≤N/p 转化为求(x,y)=1且1≤x,y≤n的个数 求(x,y)=1且1≤x,y≤N的个数: 若x...原创 2018-03-30 19:07:36 · 222 阅读 · 0 评论 -
【POJ 2478】 Farey Sequence
【题目链接】 点击打开链接【算法】 不难看出,ans = phi(2) + phi(3) + .... + phi(n-1) + phi(n) 线性筛筛出欧拉函数,预处理前缀和,即可【代码】 #include <algorithm> #include <bitset> #include <...原创 2018-04-01 19:24:41 · 119 阅读 · 0 评论 -
【POJ 2407】 Relatives
【题目链接】 点击打开链接【算法】 欧拉函数【代码】 #include <algorithm> #include <bitset> #include <cctype> #include <cerrno> #include <clocale> #include <cmath>...原创 2018-04-01 19:27:16 · 218 阅读 · 0 评论 -
【BZOJ 3884】 上帝与集合的正确用法
【题目链接】 点击打开链接【算法】 通过欧拉拓展定理,列出递推公式 【代码】 #include<bits/stdc++.h> using namespace std; typedef long long ll; ll T,N; map<ll,ll> M; template <typename T>...原创 2018-03-28 18:39:29 · 275 阅读 · 0 评论