当前位置:网站首页>[PTA] 7-24 minimum fraction (15 points)
[PTA] 7-24 minimum fraction (15 points)
2022-07-25 22:52:00 【Panzer_ Jack】
The score can be expressed as molecular / The denominator In the form of . Write a program , Ask the user to enter a score , Then it is reduced to the simplest fraction . The simplest fraction means that the numerator and denominator have no reducible components . Such as 6/12 Can be roughly divided into 1/2. When the numerator is greater than the denominator , It doesn't need to be expressed as an integer and a fraction , namely 11/8 still 11/8; And when the numerator and denominator are equal , Still expressed as 1/1 The fractional form of .
Input format :
Input gives a score in one line , Use a slash between the numerator and denominator / Separate , Such as :12/34 Express 34 Divided 12. Both numerator and denominator are positive integers ( It doesn't contain 0, If you don't know the definition of positive integers ).
Tips :
- about C Language , stay
scanfAdd... To the format string of/, Give WayscanfTo handle this slash . - about Python Language , use
a,b=map(int, input().split('/'))This code handles the slash .
Output format :
Output the simplest fraction corresponding to this score in one line , The format is the same as that entered , using molecular / The denominator The fraction is expressed in the form of . Such as 5/6 Express 6 Divided 5.
sample input :
66/120
sample output :
11/20#include <stdio.h>
int main(void)
{
int a, b, i, t, j;
scanf("%d/%d", &a, &b);
if (a>b)
{
t = a;
}
else
{
t = b;
}
for (j=1; j<=t; j++)
{
for (i=1; i<=t; i++)
{
if (a%i==0 && b%i==0)
{
a /= i;
b /= i;
}
}
}
printf("%d/%d", a, b);
}
边栏推荐
- [training day15] simple calculation [tree array] [mathematics]
- 【自然语言处理】【向量表示】AugSBERT:改善用于成对句子评分任务的Bi-Encoders的数据增强方法
- Stack simulation queue
- JS makes elements get or lose focus
- Hcie is finally in hand, and the road begins
- Scratch seamless butt bron filter
- How painful is it to write unit tests?
- [training day13] out race [mathematics] [dynamic planning]
- ribbon 执行逻辑源码解析
- 【集训DAY11】Nescafe【贪心】
猜你喜欢

Opencv compile and call GPU version

技术美术百人计划学习笔记(2)--向量

QT的Tree View Model示例

Deep recursion, deep search DFS, backtracking, paper cutting learning.

We media people must have four material websites, and don't worry about finding materials anymore

Kibana~ the process number cannot be found after kibana is started in the background

DHCP first static experiment

DOM event binding

【集训DAY12】X equation 【高精度】【数学】

Share two music playing addresses
随机推荐
HCIE终到手,路才开始
Experiment 1, experiment 2 and Experiment 3 of assembly language and microcomputer principle: branch program design / loop program design / subroutine design
[文献阅读] - HRL -[HRL with Universal Policies for Multi-Step Robotic Manipulation]
Severely crack down on illegal we media operators according to law: it is urgent to purify the we media industry
Similarities and differences between equals and "= ="
Session and cookie, token and storage
DHCP first static experiment
Use of qvariant
Von Neumann architecture
Mocha test
软件测试 pytest pytest的命名规则 用例的前后置 conftest.py 定制allure报告 @pytest.mark.parametrize()装饰器作数据驱动
How painful is it to write unit tests?
【MySQL提权】UDF提权(附带大马)
[training Day12] tree! Tree! Tree! [greed] [minimum spanning tree]
技术美术百人计划学习笔记(2)--向量
JVM memory area
Express framework
3 lexical analysis
面试题 17.11. 单词距离 ●●
Short circuit and &, short circuit or |, logic and &, logic or |; Conditional operator