【PAT乙级】1062 最简分数 (20 分)
20 PAT 乙级
2023-09-11 14:15:52 时间
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
return b?gcd(b,a%b):a;
}
int main(void)
{
int a1,b1,a2,b2,k; scanf("%d/%d %d/%d %d",&a1,&b1,&a2,&b2,&k);
double l=a1*1.0/b1,r=a2*1.0/b2;
bool flag=false;
if(l>r) swap(l,r);
for(int i=1;i<k;i++)
{
double temp=i*1.0/k;
if(temp-l>=1e-8&&r-temp>=1e-8&gcd(i,k)==1)
{
if(flag) cout<<" ";
printf("%d/%d",i,k);
flag=1;
}
}
}
相关文章
- 【C/C++学院】(20)QT:udp通信
- [SAA + SAP] 20. Other services - 1 (StackSets, EMR, SWF, Opsworks, WorkSpaces)
- vue.js3.2.20: 使用svg(svg-sprite-loader@6.0.9)
- 读书笔记--SQL必知必会20--管理事务处理
- [HW] OJ记录20题之二
- 1018 锤子剪刀布 (20 分)—PAT (Basic Level) Practice (中文)
- 1017 A除以B (20 分)—PAT (Basic Level) Practice (中文)
- 1087 有多少不同的值 (20 分)—PAT (Basic Level) Practice (中文)
- 1013 数素数 (20 分)—PAT (Basic Level) Practice (中文)
- 1009 说反话 (20 分)—PAT (Basic Level) Practice (中文)
- AI:2020年6月22日北京智源大会演讲分享之认知神经基础专题论坛——13:40-14:20毕彦超教授《Knowledge representation in the Human brain》
- TCP/IP协议族-----20、远程登录:TELNET与SSH
- 习题 5.6 求1!+2!+3!+4!+···+20!。
- PAT A 1065. A+B and C (64bit) (20)
- 【Deepin 20系统】Linux系统安装Anaconda和Tensorflow-gpu2.3