From 2f674dc80f0382f1c3178f435714960734dc9d3c Mon Sep 17 00:00:00 2001 From: Nguyễn Gia Phong Date: Sat, 6 Jun 2020 21:33:13 +0700 Subject: Reorganize stuff from secondary school --- 09/TP-HN-2014/cau1.cpp | 51 -------------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 09/TP-HN-2014/cau1.cpp (limited to '09/TP-HN-2014/cau1.cpp') diff --git a/09/TP-HN-2014/cau1.cpp b/09/TP-HN-2014/cau1.cpp deleted file mode 100644 index 274cef6..0000000 --- a/09/TP-HN-2014/cau1.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include -#include - -using namespace std; - -long -gcd(long x, long y) -{ - long z; - while (y) - { - z = x; - x = y; - y = z % x; - } - - return x; -} - -int -main() -{ - ifstream infile; - long a, b, c, d; - infile.open("CAU1.INP"); - infile >> a >> b >> c >> d; - infile.close(); - - long y = b * d / gcd(b, d); - long x = a * y / b - c * y / d; - if (!x) - y = 1; - else - { - a = gcd(x, y); - x /= a; - y /= a; - if (y < 0) - { - x *= -1; - y *= -1; - } - } - - ofstream outfile; - outfile.open("CAU1.OUT"); - outfile << x << ' ' << y << endl; - outfile.close(); - - return 0; -} -- cgit 1.4.1