Бодолт илгээх | Бүх бодолтууд | Шилдэг бодолтууд | Жагсаалт руу буцах |
RGB7315 - Бутархайг хураа |
Өгөгдсөн энгийн бутархайг хураа.
Input
Энгийн бутархайн хүртвэр, хуваарийг натурал хоёр тоо нэг зайгаар тусгаарлагдан өгөгдөнө.
Output
Хураагдсан бутархайн хүртвэр, хуваарь нь дараах хэлбэртэйгээр хэвлэгдэнэ.
хүртвэр/хуваарь
Example
Input: 9 15 Output: 3/5
Нэмсэн: | Bataa |
Огноо: | 2013-01-11 |
Хугацааны хязгаарлалт: | 1s |
Эх кодын хэмжээний хязгаарлалт: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Програмчлалын хэлүүд: | ADA95 ASM32 BASH BF C NCSHARP CSHARP C++ 4.3.2 CPP C99 CLPS LISP sbcl LISP clisp D ERL FORTRAN HASK ICON ICK JAVA JS-RHINO JULIA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON PYPY3 PYTHON3 RUBY SCALA SCM guile ST TCL WHITESPACE |
hide comments
|
||||||
2022-03-30 11:23:36
#include<stdio.h> int main() { int a, b, i=0, c, d, e; scanf("%d%d", &a, &b); for(i=1; i<=a&&b; i++) if(a%i==0&&b%i==0) c=i; e=a/c; d=b/c; printf("%d/%d", e, d); return 0; } huuulll alnuudaaa chingisss gang |
||||||
2022-01-05 14:38:17
#include<stdio.h> int main() { int a,b,c; scanf("%d %d",&a,&b); c=a; while(true) { if(a%c==0 && b%c==0)break; c--; } printf ("%d/%d" ,a/c ,b/c); } pls copy this hamgiin ez ni shuu hha bas l nodlin comment bicij bsin bn hahaha |
||||||
2021-12-06 04:42:57
#include<iostream> using namespace std; int main () { int A, B, a, b, c; cin >> A >> B ; for(int i=1; i<=A && i<=B; i++ ){ if(A%i==0 && B%i==0){ c=i; } } a=A/c; b=B/c; cout<<a<<"/"<<b; } |
||||||
2021-11-09 07:30:58
#include <iostream> using namespace std; int main() { int a, b, tempory_a, tempory_b, a1, b1; cin >> a; cin >> b; tempory_a = a; tempory_b = b; while(tempory_a != tempory_b) { if(tempory_a > tempory_b) { tempory_a = tempory_a - tempory_b; } else { tempory_b = tempory_b - tempory_a; } } a1 = a / tempory_a; b1 = b / tempory_b; cout << a1 << "/" << b1; } now i am here with CPP bcz CPP is faster than python |
||||||
2021-11-09 07:21:41
try: a, b = [int(x) for x in input().split()] tempory_a = a tempory_b = b while tempory_a is not tempory_b: if tempory_a > tempory_b: tempory_a = tempory_a - tempory_b else: tempory_b = tempory_b - tempory_a a1 = a // tempory_a b1 = b // tempory_a print(str(a1) + "/" + str(b1)) except ValueError as e: print(e) print("pls Enter integer for a and b") maybe this is fancier |
||||||
2021-11-09 07:20:40
try: a, b = [int(x) for x in input().split()] tempory_a = a tempory_b = b while tempory_a is not tempory_b: if tempory_a > tempory_b: tempory_a = tempory_a - tempory_b else: tempory_b = tempory_b - tempory_a a1 = a // tempory_a b1 = b // tempory_a print(str(a1) + "/" + str(b1)) except ValueError: print("pls Enter integer for a and b") I am here with python |
||||||
2021-11-08 10:11:53
huulmaargui sangdtal comment bichhima |
||||||
2021-10-14 15:14:34
hetsuu bodlogo baina da |
||||||
2021-04-18 17:23:10
#include<stdio.h> int main() { long long a,b,k; scanf("%lld %lld",&a,&b); k=a; while(true) { if (a%k==0 && b%k==0 ) break; k--; } printf("%lld/%lld",a/k, b/k); return 0; } haayaa huulhad bas gemgu amarhan bodolt juu haahaah |
||||||
2021-01-04 10:44:06
#include <iostream> using namespace std; int main() { int n1, n2, i = 2; cin >> n1 >> n2; do { if(n1 % i == 0 && n2 % i == 0) { n1 /= i; n2 /= i; } else i++; } while (n1 > i || n2 > i); cout << n1 << "/" << n2; return 0; } mini olson arga |