From 10de10a507238f3be43dee304e057679b5bb2736 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Wed, 9 Nov 2016 21:39:26 +0700 Subject: Thêm đề TP 12 năm 2015-2016 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 12/TP-HN-2015/bai1.pas | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 12/TP-HN-2015/bai1.pas (limited to '12/TP-HN-2015/bai1.pas') diff --git a/12/TP-HN-2015/bai1.pas b/12/TP-HN-2015/bai1.pas new file mode 100644 index 0000000..312f2b4 --- /dev/null +++ b/12/TP-HN-2015/bai1.pas @@ -0,0 +1,38 @@ +var + a, b, c, x, v: smallint; + f: text; + + +function gcd(m, n: smallint): smallint; + var + p: smallint; + + begin + while (n <> 0) do + begin + p := m mod n; + m := n; + n := p + end; + + exit(m) + end; + + +begin + assign(f, 'BAI1.INP'); + reset(f); + read(f, a, b, c); + close(f); + + v := 0; + for x := 1 to c div a do + if ((c - a * x) mod b = 0) and + (gcd(x, (c - a * x) div b) = 1) then + inc(v); + + assign(f, 'BAI1.OUT'); + rewrite(f); + writeln(f, v); + close(f) +end. -- cgit 1.4.1