当前位置:网站首页><C>. Rolling phase division
<C>. Rolling phase division
2022-06-25 19:58:00 【Yuueki XY39】
Count two numbers a,b When the greatest common divisor of , You can use the rolling division method .
for example 24 18
24%18 be equal to 6, It means that it cannot be divisible
I'll put b=18 This value , Assign to a=24
Add the remainder 6 Assign to b, became
18%6 be equal to 0, therefore b=6 Is my greatest common divisor
Write according to this idea :
#include<stdio.h>
int main()
{
int a = 0;
int b = 0;
scanf("%d %d", &a, &b);
int m = 0;
while (m = a % b)
{
a = b;
b = m;
}
printf("%d", b);
return 0;
}
Expand :
As long as we know the greatest common divisor m, Then the least common multiple =(a*b)/m
The greatest common multiple , Just a b The largest of the two numbers , Divide down one by one , Until the remainder is 0 The number of is the greatest common multiple
边栏推荐
- Mysql database design suggestions
- LNMP compilation and installation
- Huawei released two promotion plans to promote AI talent development and scientific research innovation
- Please do not call Page constructor in files
- mysql load data infile
- Lilda Bluetooth air conditioning receiver helps create a more comfortable road life
- Install spoole
- Analyse du code source du processus d'acquisition et de connexion hikaricp II
- Arduino ide + esp8266+mqtt subscribe to publish temperature and humidity information
- What are Baidu collection skills? 2022 Baidu article collection skills
猜你喜欢

Ali visual AI training camp -day03- construction of electronic photo album (face and expression recognition)

Single chip microcomputer line selection method to store impression (address range) method + Example

How to understand var = a = b = C = 9? How to pre parse?

Use of serialize() and serializearray() methods for form data serialization

Applet canvas generate sharing Poster

Vulnhub range - correlation:2

Google cloud SSH enable root password login

Wechat applet connects to the server to display mqtt data information

Embark on a new journey and reach the world with wisdom

Automatic fitting when the applet reaches the top
随机推荐
PAT B1059
PAT B1071
Divine reversion EA
Analyse du code source du processus d'acquisition et de connexion hikaricp II
Bindgetuserinfo will not pop up
Is it safe to open an account with flush?
五、HikariCP源码分析之初始化分析二
System optimization method
Mail monitoring cloud script execution progress
Wechat applet connects to the server to display mqtt data information
Suddenly found that the screen adjustment button can not be used and the brightness can not be adjusted
Uni app through uni Navigateto failed to pass parameter (pass object)
Server journey from scratch - Yu Zhongxian integrated version (IP access server, LNMP compilation and installation, Lua environment and socket expansion)
The meanings of /32, /48, /64 in IPv6 addresses
Applet multi image to Base64 upload
Processing method for uniapp or applet onload not receiving parameters
Record Baidu search optimization thinking analysis
Embark on a new journey and reach the world with wisdom
在打新債開戶證券安全嗎?低傭金靠譜嗎
How to understand var = a = b = C = 9? How to pre parse?