about summary refs log tree commit diff
path: root/2ndary/12/TP-HN-2015/bai1.pas
diff options
context:
space:
mode:
Diffstat (limited to '2ndary/12/TP-HN-2015/bai1.pas')
-rw-r--r--2ndary/12/TP-HN-2015/bai1.pas38
1 files changed, 38 insertions, 0 deletions
diff --git a/2ndary/12/TP-HN-2015/bai1.pas b/2ndary/12/TP-HN-2015/bai1.pas
new file mode 100644
index 0000000..312f2b4
--- /dev/null
+++ b/2ndary/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.