about summary refs log tree commit diff
path: root/others/volume1/008.pas
blob: 2d0f2d05ebb512fd4c81da4fa94cd624e97b331d (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
var
  n, d, m, i: byte;
  p: qword = 1;

begin
  readln(n);
  d := n div 3;
  m := n mod 3;

  if n < 3 then
    begin
      writeln(n);
      exit
    end;

  if m = 1 then
    begin
      for i := 2 to d do
        p := p * 3;
      p := p * 4
    end
  else
    for i := 1 to d do
      p := p * 3;

  if m = 2 then
    p := p * 2;

  writeln(p)
end.