
3.GCD+LCM
文章平均质量分 65
DTL66
细节决定成败
展开
-
欧几里德及扩展欧几里德算法总结
1.欧几里德: 应用:用于求a,b的最大公约数:递归解法:__int64 gcd(__int64 a,__int64 b)//求解a,b的最大公约数 { if(a%b==0)//b为最大公约数 return b; return gcd(b,a%b);//gcd(a,b)=gcd(b,a%b) } 非递归解法:__int64 gcd(__int64 a,__in原创 2016-07-31 15:42:08 · 362 阅读 · 0 评论 -
UVA - 11889 Benefit【LCM】
Recently Yaghoub is playing a new trick to sell some more. When somebody gives him A Tomans, hewho never has appropriate changes, asks for B Tomans such that lowest common multiple of A and Bequal原创 2016-11-22 12:28:06 · 403 阅读 · 0 评论 -
NYOJ 977 最大的最小公倍数
最大的最小公倍数时间限制:1000 ms | 内存限制:32768 KB难度:2描述 高中时我们对最小公倍数就已经很熟悉了,相信你很快就可以把这个问题解决。这次的问题是:给你一个正整数n,任取三个不大于n的正整数,取法不限,每个数可取多次,使得取到的这三个数的最小公倍数在所有取法中是最大的。 例如当n = 5 时,不大于5的数为1、2、3、4、5。则原创 2016-12-04 15:21:36 · 500 阅读 · 0 评论 -
HPU 1046: QAQ的数学问题 【贝祖定理】
1046: QAQ的数学问题 [数学]时间限制: 1 Sec 内存限制: 128 MB提交: 61 解决: 11[提交][状态][讨论版]题目描述QAQ很喜欢数学,尤其对LCMLCM(最小公倍数)很感兴趣。对于数对(6,10)(6,10),可以得出LCM(6,10)=30LCM(6,10)=30。为了让LCMLCM的值最小化,他尝试把66和1010全部加上22,原创 2016-12-01 14:25:28 · 817 阅读 · 0 评论 -
HihoCode 1284 : 机会渺茫【约数个数】
#1284 : 机会渺茫Time Limit:5000msCase Time Limit:1000msMemory Limit:256MBDescription小Hi最近在追求一名学数学的女生小Z。小Z其实是想拒绝他的,但是找不到好的说辞,于是提出了这样的要求:对于给定的两个正整数N和M,小Hi随机选取一个N的约数N',小Z随机选取一原创 2016-11-01 13:36:39 · 494 阅读 · 0 评论 -
ZZULI OJ Contest - 东北省赛训练赛 Problem F: 蛤玮买好了礼物 【GCD】
Contest - 东北省赛训练赛Problem F: 蛤玮买好了礼物Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 510 Solved: 200SubmitStatusWeb BoardDescription蛤玮的妹子过生日,蛤玮把千辛万苦挑选出来的礼物送到了妹子面前,然而妹子非常生气,因为妹子原创 2016-09-21 14:29:26 · 458 阅读 · 0 评论 -
HDU 5505 GT and numbers【思维+GCD】
GT and numbersTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1839 Accepted Submission(s): 500Problem DescriptionYou ar原创 2016-09-18 22:26:56 · 371 阅读 · 0 评论 -
ZZULI-1905 小火山的跳子游戏 【GCD+LCM】
Contest - 多校训练2(小火山专场)Problem A: 小火山的跳子游戏Time Limit: 1 Sec Memory Limit: 128 MB Submit: 384 Solved: 65SubmitStatusWeb Board Description小火山和火山火山在一块玩跳子游戏。规则如下: 1:跳子的起始位置为0,棋盘大小从1到N 2:每次跳子跳k步。 例原创 2016-08-10 19:14:43 · 388 阅读 · 0 评论 -
CodeForces 632B Co-prime Array 【GCD(互质)】
Co-prime ArrayTime Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u DescriptionYou are given an array of n elements, you must make it a co-prime array in as few moves as possib原创 2016-08-22 20:59:32 · 374 阅读 · 0 评论 -
A - Wolf and Rabbit
A - Wolf and RabbitTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionThere is a hill with n holes around. The holes are signed fro原创 2016-07-20 17:56:46 · 336 阅读 · 0 评论 -
C - 又见GCD
C - 又见GCDTime Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmitStatusDescription有三个正整数a,b,c(0Input第一行输入一个n,表示有n组测试数据,接下来的n行,每行输入两个正整数a,b。 Output输出对应的c,每组测试数原创 2016-07-20 18:42:41 · 342 阅读 · 0 评论 -
Cake
CakeTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3485 Accepted Submission(s): 1813Problem Description 一次生日Party可能有p人或者q人参加,现准备有一个大蛋糕.问最少原创 2016-07-20 17:47:16 · 278 阅读 · 0 评论 -
D - 最小公倍数
D - 最小公倍数 Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u SubmitStatus Description 给定两个正整数,计算这两个数的最小公倍数。Input 输入包含多组测试数据,每组只有一行,包括两个不大于1000的正整数.Output 对于每个测试用例,给原创 2016-07-20 19:08:35 · 325 阅读 · 0 评论 -
UVA - 11388 GCD LCM
The GCD of two positive integers is the largest integer that divides both the integers without anyremainder. The LCM of two positive integers is the smallest positive integer that is divisible by bo原创 2016-11-22 12:33:44 · 547 阅读 · 0 评论