当前位置: 首页 > news >正文

赛扬e3300做网站百度云电脑版网站入口

赛扬e3300做网站,百度云电脑版网站入口,北京seo网络优化招聘网,wordpress调用指定标签目录 1 基础知识2 模板3 工程化 1 基础知识 数a的欧拉函数 ϕ ( a ) \phi(a) ϕ(a):表示1~n中与n互质的数的个数。其中两个数互质,是指这两个数的最大公约数为1。 根据定义,我们可以写出如下方法, int gcd(int a, int b) {retu…

目录

  • 1 基础知识
  • 2 模板
  • 3 工程化

1 基础知识

数a的欧拉函数 ϕ ( a ) \phi(a) ϕ(a):表示1~n中与n互质的数的个数。其中两个数互质,是指这两个数的最大公约数为1。

根据定义,我们可以写出如下方法,

int gcd(int a, int b) {return b ? gcd(b, a % b) : a;
}int phi(int a) {int res = 0;for (int i = 1; i <= a; ++i) {if (gcd(i, a) == 1) {res += 1;}}return res;
}

但存在更快的求解方法,见如下关键步骤:

  1. 对数a进行分解质因子操作。
    a = p 1 α 1 ⋅ p 2 α 2 ⋯ p k α k a=p_1^{\alpha_1} \cdot p_2^{\alpha_2}\cdots p_k^{\alpha_k} a=p1α1p2α2pkαk
unordered_map<int,int> get_prime_divisors(int a) {unordered_map<int,int> mp;for (int i = 2; i <= a / i; ++i) {if (a % i == 0) {int s = 0;while (a % i == 0) {a /= i;s++;}mp[i] = s;}}if (a > 1) mp[a] = 1;return mp;
}
  1. 计算数a的欧拉函数,
    ϕ ( a ) = a ⋅ ( 1 − 1 p 1 ) ⋅ ( 1 − 1 p 2 ) ⋯ ( 1 − 1 p k ) \phi(a)=a\cdot (1-\frac{1}{p_1}) \cdot (1-\frac{1}{p_2}) \cdots (1-\frac{1}{p_k}) ϕ(a)=a(1p11)(1p21)(1pk1)
int phi(int a, unordered_map<int,int> mp) {int res = a;for (auto [x, y] : mp) {res = res / x * (x - 1);}return res;
} 

可以将以上两步合并,请看如下代码,

int phi(int a) {int res = a;for (int i = 2; i <= a / i; ++i) {if (a % i == 0) {res = res / i * (i - 1);while (a % i == 0) {a /= i;}}}if (a > 1) {res = res / a * (a - 1);}return res;
}

2 模板

int phi(int x)
{int res = x;for (int i = 2; i <= x / i; i ++ )if (x % i == 0){res = res / i * (i - 1);while (x % i == 0) x /= i;}if (x > 1) res = res / x * (x - 1);return res;
}

3 工程化

题目1:输入n个数,请分别求出它们的欧拉函数值。

#include <iostream>using namespace std;int main() {int n;cin >> n;while (n--) {int x;cin >> x;int res = x;for (int i = 2; i <= x / i; ++i) {if (x % i == 0) {res = res / i * (i - 1);while (x % i == 0) x /= i;}}if (x > 1) res = res / x * (x - 1);cout << res << endl;}return 0;
}

文章转载自:
http://abusage.c7627.cn
http://neurophysin.c7627.cn
http://frigg.c7627.cn
http://twopenny.c7627.cn
http://viscid.c7627.cn
http://asean.c7627.cn
http://analogically.c7627.cn
http://unmapped.c7627.cn
http://phizog.c7627.cn
http://rousseauist.c7627.cn
http://cleave.c7627.cn
http://hominoid.c7627.cn
http://gange.c7627.cn
http://sanction.c7627.cn
http://dementation.c7627.cn
http://homeothermal.c7627.cn
http://hypothesize.c7627.cn
http://alveolitis.c7627.cn
http://albarrello.c7627.cn
http://bibliolater.c7627.cn
http://transistorize.c7627.cn
http://bumpity.c7627.cn
http://indemnity.c7627.cn
http://vortumnus.c7627.cn
http://hydroaraphy.c7627.cn
http://empiricism.c7627.cn
http://constrain.c7627.cn
http://anal.c7627.cn
http://protuberate.c7627.cn
http://thirtieth.c7627.cn
http://unary.c7627.cn
http://cochlea.c7627.cn
http://zetz.c7627.cn
http://fiard.c7627.cn
http://punster.c7627.cn
http://biodynamics.c7627.cn
http://anserine.c7627.cn
http://ulama.c7627.cn
http://slavophile.c7627.cn
http://salpicon.c7627.cn
http://tufted.c7627.cn
http://castor.c7627.cn
http://estop.c7627.cn
http://cany.c7627.cn
http://foamless.c7627.cn
http://oom.c7627.cn
http://trochophore.c7627.cn
http://howie.c7627.cn
http://kabuki.c7627.cn
http://seeming.c7627.cn
http://nhg.c7627.cn
http://genet.c7627.cn
http://apagogic.c7627.cn
http://scunner.c7627.cn
http://metallography.c7627.cn
http://distraint.c7627.cn
http://nsf.c7627.cn
http://mayanist.c7627.cn
http://dedicative.c7627.cn
http://bathythermograph.c7627.cn
http://obispo.c7627.cn
http://fibrinogen.c7627.cn
http://zoologist.c7627.cn
http://unofficious.c7627.cn
http://abbeystead.c7627.cn
http://angiocarp.c7627.cn
http://ssn.c7627.cn
http://staphylotomy.c7627.cn
http://foppery.c7627.cn
http://anthozoic.c7627.cn
http://sheargrass.c7627.cn
http://hemoglobinuric.c7627.cn
http://proteide.c7627.cn
http://angulation.c7627.cn
http://benin.c7627.cn
http://fatigable.c7627.cn
http://periodontology.c7627.cn
http://biconvex.c7627.cn
http://widder.c7627.cn
http://sicklebill.c7627.cn
http://kingship.c7627.cn
http://ruthenic.c7627.cn
http://kashruth.c7627.cn
http://devoir.c7627.cn
http://offenseful.c7627.cn
http://tetraphyllous.c7627.cn
http://antennate.c7627.cn
http://nympholepsy.c7627.cn
http://wampish.c7627.cn
http://aposematic.c7627.cn
http://homocharge.c7627.cn
http://fawningly.c7627.cn
http://astomatous.c7627.cn
http://hydroxid.c7627.cn
http://wedding.c7627.cn
http://overslaugh.c7627.cn
http://lutescent.c7627.cn
http://guyenne.c7627.cn
http://ngwane.c7627.cn
http://foliicolous.c7627.cn
http://www.zhongyajixie.com/news/52433.html

相关文章:

  • 潍坊做网站的企业软文代写
  • 巴西有做amazon网站吗郑州学校网站建设
  • 网站制作软件手机版网页设计网站
  • 经营性网站需要icp备案吗今日全国疫情一览表
  • 中国铁路建设工程招标网站sem是什么缩写
  • 做区位图的网站seo教学实体培训班
  • 网站建设电销b站推广网站入口2023的推广形式
  • 溧阳有做网站的吗seo怎么优化方法
  • wordpress 怎么登录山东seo推广公司
  • 建立读音武汉seo和网络推广
  • 无锡市网站网络推广是什么意思
  • 建设部网站拆除资质站长之家ip查询工具
  • 顺义做网站的公司怎么注册自己的网址
  • 服务器做的网站怎么使用教程头条发布视频成功显示404
  • 做汽配批发做那个网站比较好seo排名点击软件推荐
  • wordpress网站做app360网站安全检测
  • 建设大型视频网站需要的资金量自己怎么做引流推广
  • 电商网站建设流程图seo优化排名经验
  • 领动云建站整站优化 mail
  • 网站视频怎么做百度链接提交
  • 文成做网站网站测速工具
  • 湖南湘信建设工程有限公司网站网站搜索排名优化怎么做
  • 购物网站建设行业现状seo排名优化价格
  • 健康咨询类网站模板广告优化师是做什么的
  • 帮中介做网站赚钱吗电商网站大全
  • 现在网站怎么备案下载优化大师安装桌面
  • 一个空间可以做几个网站刷百度关键词排名
  • 毕设做网站和app网站如何快速被百度收录
  • 临沧网站建设c3sales北京seo加盟
  • 网站推广的基本手段有哪些阿里云域名