about summary refs log tree commit diff
path: root/12/TP-HN-2015/bai1.pas
blob: 312f2b48176826539bc522d2f2ddd9029d16ad40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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.