E-COM-NET
首页
在线工具
Layui镜像站
SUI文档
联系我们
推荐频道
Java
PHP
C++
C
C#
Python
Ruby
go语言
Scala
Servlet
Vue
MySQL
NoSQL
Redis
CSS
Oracle
SQL Server
DB2
HBase
Http
HTML5
Spring
Ajax
Jquery
JavaScript
Json
XML
NodeJs
mybatis
Hibernate
算法
设计模式
shell
数据结构
大数据
JS
消息中间件
正则表达式
Tomcat
SQL
Nginx
Shiro
Maven
Linux
divisors
AtCoder备赛刷题 ABC 383 | 9
Divisors
学习C++从娃娃抓起!记录下AtCoder(日本算法竞技网站)备赛学习过程中的题目,记录每一个瞬间。附上汇总贴:AtCoder备赛刷题|汇总【题目描述】FindthenumberofpositiveintegersnotgreaterthanNNNthathaveexactly999positivedivisors.找到不大于NNN且恰好有999个因数的正整数的数量。【输入】Theinputisg
热爱编程的通信人
·
2025-02-03 14:54
算法
数论(三)——约数(约数个数,约数和,公约数)
时间复杂度:O(sqrt(n))vectorget_
divisors
(intn){vectorres;//vector数组存储一个数的所有约数
DearLife丶
·
2025-01-28 12:16
#
数学知识
算法
gcd
约数
欧几里德算法
Two
Divisors
(数学)
Problem-B-Codeforces#includeusingnamespacestd;#defineintlonglongconstintN=2e5+5;inta,b;voidsolve(){scanf("%lld%lld",&a,&b);intp=a/__gcd(a,b)*b;if(b%a==0)cout<
陈进士学习
·
2024-02-06 19:34
codeforces
算法
c语言
c++
数据结构
数学
数论 - 约数基础 【 试除法求所有约数 + 约数个数和约数之和 + 欧几里得算法-求解最大公约数 】
2.试除法求所有约数vectorget_
divisors
(in
林小鹿@
·
2024-02-06 17:09
算法笔记
约数
欧几里得
约数之和
Two
Divisors
#includeusingnamespacestd;intgcd(inta,intb){returnb>0?gcd(b,a%b):a;}voidsolve(){inta,b;cin>>a>>b;longlongans=(longlong)a*b/gcd(a,b);longlongx=0;if(ans>b)x=ans;elsex=b/a*b;cout>t;while(t--)solve();retu
三冬四夏会不会有点漫长
·
2024-02-06 17:04
#
CF
900-1000
算法
Insert Greatest Common
Divisors
in Linked List
文章目录一、题目二、题解一、题目Giventheheadofalinkedlisthead,inwhicheachnodecontainsanintegervalue.Betweeneverypairofadjacentnodes,insertanewnodewithavalueequaltothegreatestcommondivisorofthem.Returnthelinkedlistaft
叶卡捷琳堡
·
2024-01-11 13:48
leetcode
算法
数据结构
c++
【LeetCode每日一题】2807. 在链表中插入最大公约数(模拟+求最大公约数的6中写法)
2024-1-6文章目录[2807.在链表中插入最大公约数](https://leetcode.cn/problems/insert-greatest-common-
divisors
-in-linked-list
翁佳明
·
2024-01-07 11:25
LeetCode
leetcode
链表
算法
Insert Greatest Common
Divisors
in Linked List
Giventheheadofalinkedlisthead,inwhicheachnodecontainsanintegervalue.Betweeneverypairofadjacentnodes,insertanewnodewithavalueequaltothegreatestcommondivisorofthem.Returnthelinkedlistafterinsertion.Theg
Recursions
·
2024-01-07 00:02
算法
LeetCode 2807.在链表中插入最大公约数
【LetMeFly】2807.在链表中插入最大公约数力扣题目链接:https://leetcode.cn/problems/insert-greatest-common-
divisors
-in-linked-list
Tisfy
·
2024-01-06 13:17
题解
#
力扣LeetCode
leetcode
链表
算法
题解
最大公约数
【算法基础15】如何求约数?约数个数?约数之和?最大公约数?
vectorget_
divisors
(intn){vectorres;for(inti=1;i#include#include#includeusingnamespacestd;typed
努力努力的脆脆鲨
·
2024-01-05 01:28
算法基础
算法
c++
数据结构
算法中的数学一:判定质数和求约数相关
试除法求质数质数就是大于1的整数中除了1和自身没有其他因数的数1.1暴力求解暴力求解的思路就是从2遍历到自身判断是否有被整除的数,时间复杂度为O(n)的boolis_prime(intx){if(xget_
divisors
计科小fw是我
·
2023-12-25 17:26
算法中的数学
算法
acwing算法基础之数学知识--求一个数x的约数数目和约数之和
分解质约数,x=p1c1⋅p2c2⋯pkckx=p_1^{c_1}\cdotp_2^{c_2}\cdotsp_k^{c_k}x=p1c1⋅p2c2⋯pkckunordered_mapget_prime_
divisors
YMWM_
·
2023-11-14 11:00
Acwing
C++学习
算法
acwing算法基础之数学知识--求数a的欧拉函数值phi(a)
gcd(b,a%b):a;}intphi(inta){intres=0;for(inti=1;iget_prime_
divisors
(inta){unor
YMWM_
·
2023-11-14 11:56
Acwing
C++学习
算法
数学知识:约数
试除法求约数:#include#include#includeusingnamespacestd;intn;voidget_
divisors
(intn){vectorres;for(inti=1;i#includeusingnamespacestd
友纪YuKi
·
2023-10-29 06:00
哈希算法
算法
用Python代码实现1000以内的完数
编写defis_perfect_number(number):
divisors
=[1]#1是任何数的因子foriinrange(2,number):ifnumber%i==0:
divisors
.append
奈良晴雪
·
2023-10-14 17:59
python
开发语言
Three
Divisors
解题报告
Question:Givenanintegern,returntrueifnhasexactlythreepositivedivisors.Otherwise,returnfalse.Anintegermisadivisorofnifthereexistsanintegerksuchthatn=k*m.Example1:Input:n=2Output:falseExplantion:2hasonl
杨鑫newlfe
·
2023-09-25 14:19
Python
算法
LeetCode
leetcode
算法
python
数据结构
面试
题目:2644.找出可整除性得分最大的整数
解题代码:classSolution{publicintmaxDivScore(int[]nums,int[]
divisors
){intscore=0;intres=
divisors
[0];for(intdivisor
十年一觉尘与土
·
2023-09-06 03:10
#
java
leetcode
java
Divisors
of Two Integers
题目:样例:输入10102812412045输出208题意:给出一个列表数组,这个列表数组中,是两个正整数x和y的约数将它们放在了一块,请找出这两个x和y的值分别是多少。解题思路:这道题很有意思,就单纯的思维题。从给的样例我们可以知道,一定有一个最大的数作为x或者y,所以我们把这个最大的约数弄出来之后,再把剩下的数中的最大数一定就是y或者x。代码详解如下:#include#include#defi
Angindem
·
2023-09-01 00:08
玩转上号CF“游戏”
算法
数据结构
双周赛110(模拟、枚举+哈希表)
account-balance-after-rounded-purchase/)模拟[2807.在链表中插入最大公约数](https://leetcode.cn/problems/insert-greatest-common-
divisors
-in-linked-list
Miraclo_acc
·
2023-08-10 02:10
算法刷题记录
散列表
数据结构
Acwing 第四章模板及详解(数学知识)
在大于1的整数中,有且只有1和他本身两个因数的数,也叫做素数试除法判定质数1、sqrt(x),函数计算的时间比较高boolis_prime(intx){ //质数大于1 if(x1)coutget_
divisors
小吉在努力
·
2023-08-09 18:11
算法
几何学
线性代数
Longest
Divisors
Interval(cf)
题意:给定一个正整数n,求正整数的区间[l,r]的最大大小,使得对于区间中的每个i(即l≤i≤r),n是i的倍数。给定两个整数l≤r,区间[l,r]的大小为r−l+1(即,它与属于区间的整数数量一致)。输入第一行包含单个整数t(1≤t≤10^4)--测试用例的数量。每个测试用例描述的唯一一行包含一个整数nn(1≤n≤10^18)。输出对于每个测试用例,打印单个整数:有效间隔的最大大小。输入样例:1
DHX~
·
2023-08-06 18:24
算法
Longest
Divisors
Interval(连续倍数)
题目:Problem-B-Codeforces总结:对于连续的倍数,要想连续的数量越大连续的数越小对于该题遍历50就可以AC代码献上(连续倍数):#include#includeusingnamespacestd;#defineintlonglongsignedmain(){intv;cin>>v;while(v--){intn;cin>>n;intnum=0;for(inta=1;a<=100;
CCPC不拿奖不改名
·
2023-08-01 16:32
心得
经验
题解
算法
c++
数据结构
开发语言
chatgpt赋能python:Python怎么求完数
defis_perfect(n):"""判断一个数字是否为完数"""
divisors
=[
虚幻私塾
·
2023-06-15 05:28
chatgpt
python
人工智能
计算机
Python循环求素因数分解(代码)
defgen_prime(n):#定义质数生成函数list_prime=list()nums=dict()#字典key存放所有自然数,值为1表示质数,0为合数i=2whilei=1:ifn%l[i]==0:
divisors
云巅筑梦
·
2023-06-14 16:26
Python学习作业
python
素数判断
//
divisors
.c--使用嵌套if语句显示一个数的约数#include#includeintmain(){unsignedlongnum;//待测试的数unsignedlongdiv;//可能的约数
ThWh
·
2023-04-14 05:06
Different
Divisors
(素数筛/线性筛)
官网给的题解大致题意a有至少4个因子,a任一对因子之差大于等于d。求最小a分析我们找到数a的因子,首先1肯定是其因子,必须保证a的所有因子任意两个差值必须大于等于d,假设我们找到两相邻的因子m,n满足差值大于等于d,但是若m或n自身也能分解成更小的因子,那么可能存在他们的子因子的差值不能满足条件,所以我们需要求质因子。我们用素数筛存储质数存到primes[]中,然后在数组中寻找质因子满足条件即可。
diviner_s
·
2021-01-25 18:51
Codeforces
素数筛/线性筛
SPOJ - NDIV n-
divisors
(约数个数问题)
primenumberisanaturalnumbergreaterthan1thathasnopositivedivisorsotherthan1anditself.WecanClassifythenumbersbyitsnumberofdivisors,asn-
divisors
-numbers
mrcoderrev
·
2020-09-14 21:17
计算数学
Divisors
(数论+暴力)
题目链接:codeforces446E题目大意:给出一个x,k,每次操作都会将x分解因数,得到新的序列,然后每次再分解序列中的每一个数,按照每一个数分解因数从小到大排,整体顺序不做调整。题目分析:因为x是10^12以内的数,我们可以n√的预处理出x所有的因数,然后了解到其实每个因数如果一直分解深度是log(n)的复杂度,那么我们要得到这105个答案,就是对于每个因数递归的分解到1,然后输出答案,达
黎辰
·
2020-09-14 19:47
codeforces的数论专题
hdoj 1492 The number of
divisors
(约数) about Humble Numbers 【数论】【质因子分解 求和】
定理:一个正整数n可以用素因子唯一表示为p1^r1*p2^r2*...pk^rk(其中pi为素数),那么这个数的因子的个数就是,(r1+1)*(r2+1)*...*(rk+1).理解:为什么是加1之后再相乘,因为一个数的的因子数至少为1和他自身,但因为r1,r2。。可以为0,所以因子的个数为(r1+1)。。。拓展一下:定理1:一个正整数n可以用素因子唯一表示为p1^r1*p2^r2*...pk^r
shengweisong
·
2020-09-14 15:22
数论
【Java】LeetCode 1362. 最接近的因数
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/closest-
divisors
著作权归领扣网络所有。
程序猴hyx
·
2020-09-13 04:03
有趣的面试题
算法
java
PE530 : GCD of
Divisors
\[\begin{eqnarray*}ans&=&\sum_{i=1}^nf(i)\\&=&\sum_{i=1}^n\sum_{d|i}\gcd(d,\frac{i}{d})\\&=&\sum_{i=1}^n\sum_{d|i}\sum_{k|d,k|\frac{i}{d}}\varphi(k)\\&=&\sum_{k=1}^n\varphi(k)\sum_{k^2|i}\sigma_0(\fra
weixin_34101784
·
2020-08-25 05:51
Two
Divisors
CodeForces - 1366D(数论)
Youaregivennintegersa1,a2,…,an.Foreachaifinditstwodivisorsd1>1andd2>1suchthatgcd(d1+d2,ai)=1(wheregcd(a,b)isthegreatestcommondivisorofaandb)orsaythatthereisnosuchpair.InputThefirstlinecontainssinglein
starlet_kiss
·
2020-08-25 04:23
PE 439 Sum of sum of
divisors
| 51nod 1220 约数之和
题目:https://projecteuler.net/problem=439以及http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1220题意:令d(x)表示x的所有因子之和,求∑Ni=1∑Nj=1d(i∗j)mod109+7。N≤109。题解:令[x]为布尔表达式x的值,即若x为真则[x]=1,否则[x]=0。那么有d(
skywalkert
·
2020-08-25 04:16
51nod
AtCoder Beginner Contest 172 D.Sum of
Divisors
AtCoderBeginnerContest172D.SumofDivisors题目链接直接暴力出1e7内的所有数的因子数,暴力计算即可:#includeusingnamespacestd;typedeflonglongll;constintN=1e7+5;llf[N],n,ans;intmain(){for(inti=1;i>n;for(inti=1;i<=n;i++)ans+=f[i]*i;c
旺 崽
·
2020-08-25 04:51
暴力
AtCoder
Two
Divisors
-----------------------------思维(数论+gcd性质+唯一分解定理)
题意:给定n个数,对于每一个数找到两个因子d1和d2d1>1且d2>1使得gcd(d1+d2,ai)=1如果没有就输出-1解析:唯一分解定理ai=p1q1*p2q2*…pnqnd1=p1q1d2=p2q2*…pnqnd1和d2互质的因为:gcd(a,b)=gcd(a+b,b)所以:gcd(d1,d2)=gcd(d1+d2,d2);又因为:gcd(a,c)=1则gcd(a,bc)=gcd(a,b)所
AKone123456
·
2020-08-25 04:18
思维
Codeforces
AtCoder Beginner Contest 172 D - Sum of
Divisors
(类似素数筛)
题目链接:https://atcoder.jp/contests/abc172/tasks/abc172_d题意:给定一个n,f(x)表示x的因子数量,求题解:可以类比素数筛,素数筛是从2开始把它所有的倍数都划去,这边也可以用这种思想,从1开始枚举到1e7,将每个数的倍数对应的因子个数+1.代码:#includeusingnamespacestd;typedeflonglongll;constin
biuhongWA
·
2020-08-25 04:18
D - Sum of
Divisors
-----------------------思维(数论+逆向思维+枚举因子个数)
题意:求出1~n中所有数的约数个数*i解析:想到求约数,但是O(nsqrt(n))超时了。所以我们要逆向去思考,我们可以枚举i的倍数,就可以确定每个数的因子个数有多少了时间复杂度:O(nlogn)#includeusingnamespacestd;typedeflonglongll;constintN=1e7+10;llf[N];intn;intmain(){cin>>n;for(inti=1;i
AKone123456
·
2020-08-25 02:45
思维
Atcoder
AtCoder Context ABC 172 D - Sum of
Divisors
本文章为原创文章,未经过允许不得转载运行要求运行时间限制:2sec内存限制:1024MB原题链接题目给定一个正整数X,正整数的X的约数的函数为f(X)给定一个正整数N,求F(1)x1+F(2)x2....+F(N)xN输入前提条件1<=N<=10000000输出输出F(1)x1+F(2)x2....+F(N)xN例1输入4输出23f(1)=1f(2)=2f(3)=2f(4)=3所以最终的结果是1x
伟大不DIAO
·
2020-08-24 17:50
python3.x
题解 CF448E 【
Divisors
】
一道函数递归题记录一下当前的是第几层和现在要分的数是几(分别用xxx和yyy表示)然后,每一次从小到大枚举因子,继续递归直到输出的总数到达10510^5105。#include#include#definelllonglongusingnamespacestd;lla,b,tot;voiddfs(llx,lly){if(tot>=100000)return;if(!x){printf("%lld"
A_zjzj
·
2020-08-23 00:39
Divisors
POJ - 2992
题目链接YourtaskinthisproblemistodeterminethenumberofdivisorsofCnk.Justforfun--ordoyouneedanyspecialreasonforsuchausefulcomputation?InputTheinputconsistsofseveralinstances.Eachinstanceconsistsofasinglelin
cc_wood
·
2020-08-19 09:15
算法之数学
HDU 6069 Counting
Divisors
题目链接;点我Inmathematics,thefunctiond(n)denotesthenumberofdivisorsofpositiveintegern.Forexample,d(12)=6because1,2,3,4,6,12areall12’sdivisors.Inthisproblem,givenl,randk,yourtaskistocalculatethefollowingthi
cc_wood
·
2020-08-19 09:14
算法之数学
CF27E Number With The Given Amount Of
Divisors
CF27ENumberWithTheGivenAmountOfDivisors技术统计难度提高+/省选-用时30min提交次数5unaccept次数4ac次数1题意概括给定一个正整数n,输出最小的整数,满足这个整数有n个因子数据范围n≤1000n\le1000n≤1000解法、知识点dfs反素数数学QwQ解法概括首先我们明确一个问题:反素数定义:对于任意的正整数n,我们设f(n)为其因数的个数,若
Loi_magic
·
2020-08-19 08:21
刷题
Two
Divisors
(数论,线性筛)
https://codeforces.ml/contest/1366/problem/D(题目链接如上↑)题解:1.首先,gcd(x,y)=gcd(x+y,x*y)证明如下:gcd有两点性质:(1)gcd(a,b)=gcd(a-b,b),gcd(a,b)=gcd(a+b,b)(2)若gcd(a,c)=1,则gcd(a,bc)=gcd(a,b)下面正式开始证明:由性质1可得:gcd(x,y)=1->
沐兮Krystal
·
2020-08-17 11:26
Codeforces
数论题
1108B -
Divisors
of Two Integers
B.DivisorsofTwoIntegerstimelimitpertest1secondmemorylimitpertest256megabytesinputstandardinputoutputstandardoutputRecentlyyouhavereceivedtwopositiveintegernumbersxandy.Youforgotthem,butyourememberedas
我i是超人
·
2020-08-17 02:02
Two
Divisors
【GCD数论】
Youaregivennnintegersa1,a2,…,ana1,a2,…,an.Foreachaiaifinditstwodivisorsd1>1d1>1andd2>1d2>1suchthatgcd(d1+d2,ai)=1gcd(d1+d2,ai)=1(wheregcd(a,b)gcd(a,b)isthegreatestcommondivisorofaaandbb)orsaythatthere
Andres_Lionel
·
2020-08-17 02:00
数论
hdu-4432-Sum of
divisors
/*SumofdivisorsTimeLimit:2000/1000MS(Java/Others)MemoryLimit:32768/32768K(Java/Others)TotalSubmission(s):1996AcceptedSubmission(s):679ProblemDescriptionmmmislearningdivision,she'ssoproudofherselfthats
weixin_30632883
·
2020-08-15 11:01
Almost All
Divisors
、C. Good String题解
D.AlmostAllDivisors题意:给出t组测试数据,每组测试数据给出n个数,这n个数是guessednumber除去本身和1以外的所有因子,输出最小的guessednumber。思路:sort排序所有因子di,将最小的因子和最大的因子相乘,得到的既是所有guessednumber(假定此数满足题意),此时再将得到的数求出所有除本身与1之外的所有因子,与题目给出的所有因子相比较,只要因子相
KKKyot_
·
2020-08-15 11:56
题解
Codeforces Round #236 (Div. 2)
A.NutsYouhaveanutsandlotsofboxes.Theboxeshaveawonderfulfeature:ifyouputx(x ≥ 0)
divisors
(thespacialbarsthatcandivideabox
13vickey
·
2020-08-12 18:22
数学
POJ2992
Divisors
(整数分解)
DivisorsTimeLimit:1000MSMemoryLimit:65536KTotalSubmissions:10847Accepted:3214DescriptionYourtaskinthisproblemistodeterminethenumberofdivisorsofCnk.Justforfun--ordoyouneedanyspecialreasonforsuchauseful
MiniSheep_CS
·
2020-08-11 13:10
数论
HDU 1492 The number of
divisors
(约数) about Humble Numbers
ProblemDescriptionAnumberwhoseonlyprimefactorsare2,3,5or7iscalledahumblenumber.Thesequence1,2,3,4,5,6,7,8,9,10,12,14,15,16,18,20,21,24,25,27,...showsthefirst20humblenumbers.Nowgivenahumblenumber,pleas
这样啊我也喜欢
·
2020-08-10 20:21
数论
hdu
上一页
1
2
3
4
5
下一页
按字母分类:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
其他