-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathROBOT.PAS
More file actions
41 lines (41 loc) · 793 Bytes
/
ROBOT.PAS
File metadata and controls
41 lines (41 loc) · 793 Bytes
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
39
40
41
program robot;
uses crt;
var
n,i,j,e : longint;
command : array [1..100] of byte;
begin
clrscr;
readln(n);
while n <> 1 do
begin
inc(i);
if n mod 2 = 0 then
begin
command[i] := 2;
n := n div 2;
end
else
begin
command[i] := 1;
dec(n);
end;
end;
write('C1 ');
inc(e,1);
for j := i-1 downto 1 do
begin
if command[j] = 2 then
begin
write('N2 ');
inc(e,4);
end
else
begin
write('C1 ');
inc(e,2);
end;
end;
writeln;
write(e);
readln;
end.