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

宁波网站运营优化系统极速云建站

宁波网站运营优化系统,极速云建站,网站开发公司资质,dw软件主要做什么文章目录 AcWing 869. 试除法求约数题目链接思路CODE AcWing 870. 约数个数题目链接思路CODE AcWing 871. 约数之和题目链接思路CODE AcWing 872. 最大公约数题目链接思路CODE AcWing 869. 试除法求约数 题目链接 https://www.acwing.com/activity/content/problem/content/9… 文章目录 AcWing 869. 试除法求约数题目链接思路CODE AcWing 870. 约数个数题目链接思路CODE AcWing 871. 约数之和题目链接思路CODE AcWing 872. 最大公约数题目链接思路CODE AcWing 869. 试除法求约数 题目链接 https://www.acwing.com/activity/content/problem/content/938/ 思路 基于算术基本定理从最小质数开始往上除直到不含这个因数而和数都是由比它小的质数相乘得来所以所有约束都是质数。 CODE #include iostream #include cstring #include algorithm #include vectorusing namespace std;int n;vectorint get_divided(int n){vectorint res;for(int i 1; i n / i; i){if(n % i 0){res.push_back(i);if(i ! n / i) res.push_back(n / i);}}sort(res.begin(), res.end());return res; }int main() {cin n;while (n -- ){int a;scanf(%d, a);auto res get_divided(a);for(auto t : res) cout t ;puts();} }AcWing 870. 约数个数 题目链接 https://www.acwing.com/activity/content/problem/content/939/ 思路 还是基于算术基本定理一个数可以分解为唯一因式 K p 1 a 1 p 2 a 2 . . . p i a i K p1^{a1} p2^{a2} ... pi^{ai} Kp1a1p2a2...piai 那么约数的个数就是公式 ( a 1 1 ) ( a 2 1 ) . . . ( a i 1 ) (a1 1)(a2 1)...(ai 1) (a11)(a21)...(ai1) CODE #includevector #include iostream #include cstring #include algorithm #include unordered_mapusing namespace std;typedef long long ll;const int mod 1e9 7; int n;int main() {cin n;unordered_mapint, int primes;while (n -- ){int a;scanf(%d, a);for(int i 2; i a / i; i){while(a % i 0){a / i;primes[i];}}if(a 1) primes[a];}ll res 1;for(auto t : primes) res res * (t.second 1) % mod;cout res endl; }AcWing 871. 约数之和 题目链接 https://www.acwing.com/activity/content/problem/content/940/ 思路 还是基于算术基本定理 K p 1 a 1 p 2 a 2 . . . p i a i K p1^{a1} p2^{a2} ... pi^{ai} Kp1a1p2a2...piai由这个因式我们可以得到以下公式 N ( p 1 0 p 1 1 . . . p 1 a 1 ) ( p 2 0 p 2 1 . . . p 2 a 2 ) . . . ( p i 0 p i 1 . . . p i a i ) N (p1^0 p1^1 ... p1^{a1})(p2^0 p2^1 ... p2 ^ {a2})...(pi ^ 0 pi ^1 ... pi^{ai}) N(p10p11...p1a1)(p20p21...p2a2)...(pi0pi1...piai)这个公式展开就是每项约数的和。 详细推导可以参考以下视频约数个数与约数之和 CODE #include iostream #include cstring #include algorithm #include unordered_mapusing namespace std;typedef long long ll;const int mod 1e9 7; int n;int main() {cin n;unordered_mapint, int primes;while (n -- ){int a;scanf(%d, a);for(int i 2; i a / i; i){while(a % i 0){a / i;primes[i];}}if(a 1) primes[a];}ll ans 1;for(auto p : primes){ll a p.first, b p.second;ll res 1;while(b--) res (res * a 1) % mod;ans ans * res % mod;}cout ans endl; }AcWing 872. 最大公约数 题目链接 https://www.acwing.com/activity/content/problem/content/941/ 思路 辗转相除法 具体证明请看 VCR CODE #include iostream #include cstring #include algorithmusing namespace std;int gcd(int a, int b){return b ? gcd(b, a % b) : a; }int main() {int n;cin n;while(n--){int a, b;scanf(%d%d, a, b);cout gcd(a, b) endl;} }
http://www.yutouwan.com/news/12354/

相关文章:

  • 想做网站濮阳网站建设怎么看网站有没有做404
  • 网站建设培训心得wordpress 人体时钟
  • 网站开发 网页设计北京师范大学出版社知名网站制作公司青岛分公司
  • 南昌做网站公司大蒜价格国际贸易网
  • asp 网站开发实例教程安徽省建设厅官网查询
  • 深圳网站建设价格多少钱安阳网站设计哪家好
  • 济南高新网站建设简单大气的科技公司名字
  • 建设网站如入什么费wordpress 安装 模板
  • 怎样用js做网站轮播图西安千秋网络科技有限公司怎么样
  • 东莞网站建设专业品牌武进网站建设效果
  • 有没有什么做地堆的网站照片素材库网站免费
  • 北京公司网站建设服务阿里云一个域名做两个网站
  • 水泥制品做阿里巴巴还是网站好泰安市人才信息网
  • 深圳做网站980wordpress网站云备份
  • 切图网站免费网站推广文章
  • 住建部禾建设部是一个网站吗宝塔一键wordpress
  • 兰州做网站哪家好18款app软件免费下载
  • phpcms v9 网站建设入门网站建设与维护工作待遇
  • 网站建设整体情况介绍如何做兼职网站平台
  • 欢迎访问中国建设银行网站西安官网优化报价
  • 南宁网站建设哪家公司运动鞋官方网站建设计划书
  • 怎么开免费网站小程序开发需要多少钱
  • 建设专业网站排名网站建设的类型有几种
  • 陕西省建设执业注册中心网站网站建设维护专员岗位说明
  • 网站做广告费用副标题wordpress
  • p2p网站建设 上海免费网站制作教程
  • 制作网站服务公司黑龙江高端网站建设
  • 网站建设需求分析范例在线设计工具的网站怎么做
  • 自己做服装搭配的网站金昌北京网站建设
  • 一般专业网站建设公司英文网站建设方案模板高校