-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathamazon.c
More file actions
70 lines (67 loc) · 912 Bytes
/
amazon.c
File metadata and controls
70 lines (67 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include<stdio.h>
int max(int a,int b)
{
return(a>b?a:b);
}
int lcm(int a,int b)
{
if(b%a==0)
return b;
else
{
int i=2;
int lcm;
while(1)
{
int l=b*i;
if(l%a==0)
return l;
i++;
}
}
}
void main()
{
int ha=7,hb=9;
int c=0;
int ma=max(ha,hb);
if(ma==hb)
{
int lc=lcm(ha,hb);
if(lc==hb)
{
c=lc/ha;
c=c-1;
printf("c=%d",c);
}
else
{
int t1=ha;
hb=(lc/hb)*hb;//20
ha=(lc/hb)*ha;//8
c=lc/hb;//2
c=c-1;//1
c=c+(hb-ha)/t1;//1+3=4
printf("c=%d",c);
}
}
else
{
int lc=lcm(hb,ha);
if(lc==ha)
{
c=lc/hb;
c=c-1;
printf("c=%d",c);
}
else
{
int t1=hb;
hb=(lc/ha)*hb;//20
ha=(lc/ha)*ha;//8
c=lc/ha;//2
c=c-1;//1
c=c+(ha-hb)/t1;//1+3=4
printf("c=%d",c);
}
}}