diff options
author | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2016-11-09 21:39:26 +0700 |
---|---|---|
committer | Raphael McSinyx <vn.mcsinyx@gmail.com> | 2016-11-09 23:10:54 +0700 |
commit | 10de10a507238f3be43dee304e057679b5bb2736 (patch) | |
tree | 748d8f04dda4aa9ae2b71ade67eb8a0dd543e262 /12/TP-HN-2015/bai1.pas | |
parent | 94f49ef11037832a173d268ca932fe34cf78b472 (diff) | |
download | cp-10de10a507238f3be43dee304e057679b5bb2736.tar.gz |
Thêm đề TP 12 năm 2015-2016
Diffstat (limited to '12/TP-HN-2015/bai1.pas')
-rw-r--r-- | 12/TP-HN-2015/bai1.pas | 38 |
1 files changed, 38 insertions, 0 deletions
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. |