
gcd
三更鬼
这个作者很懒,什么都没留下…
展开
-
力扣 1447. 最简分数
题目来源:https://leetcode-cn.com/problems/simplified-fractions/大致题意:给你一个整数 n ,请你返回所有 0 到 1 之间(不包括 0 和 1)满足分母小于等于 n 的 最简 分数 。分数可以以 任意 顺序返回思路遍历所有的分母 2 - n遍历所有的分子 1 - n-1若当前分数为最简分数(最大公约数为 1),则放入集合代码: public List<String> simplifiedFractions(int n)原创 2022-02-10 23:00:04 · 409 阅读 · 0 评论 -
Wolf and Rabbit||HDU1222
link:http://acm.hdu.edu.cn/showproblem.php?pid=1222 Problem DescriptionThere is a hill with n holes around. The holes are signed from 0 to n-1.A rabbit must hide in one of the holes. A wolf searches t原创 2017-08-07 21:21:34 · 211 阅读 · 0 评论 -
又见GCD ||HDU2053
有三个正整数a,b,c(0int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int main(){ int a,b,c,i,t; scanf("%d",&t); while(t--) { scanf("%d%d",&a,&b原创 2017-07-24 16:57:37 · 272 阅读 · 0 评论