diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-02-11 11:37:48 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2017-02-11 11:37:48 +0700 |
commit | df9a0d140a7b7edef66f95aa13b5bb4488147f68 (patch) | |
tree | de213e8e6abf244426fcec5974c1cc247897f869 /others/volume1/006.pas | |
parent | 092019121ad5ef6f82cd8fe7bf6ee143fce9648d (diff) | |
download | cp-df9a0d140a7b7edef66f95aa13b5bb4488147f68.tar.gz |
Fast and furiously add others/volume1
Diffstat (limited to 'others/volume1/006.pas')
-rw-r--r-- | others/volume1/006.pas | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/others/volume1/006.pas b/others/volume1/006.pas new file mode 100644 index 0000000..989acba --- /dev/null +++ b/others/volume1/006.pas @@ -0,0 +1,27 @@ +var + a, b, g: int64; + c, d: longint; + + +function gcd(x, y: int64): int64; + var + z: longint; + + begin + while y > 0 do + begin + z := y; + y := x mod y; + x := z + end; + gcd := x + end; + + +begin + readln(a, b, c, d); + a := a * d + b * c; + b := b * d; + g := gcd(a, b); + writeln(a div g, ' ', b div g) +end. |