1.
program exp1;
var
a:array[1..6] of longint;
s,t,i,j:longint;
begin
a[1]:=1;t:=0;
for i:=2 to 6 do
begin
s:=0;
for j:=1 to i-1 do
s:=s+a[j];
a[i]:=s+1;
end;
for i:=1 to 6 do
t:=t+a[i];
writeln('t=',t);
end.
输出:t=63
2.
program exp2;
var a,b,f: integer;
function gd(m,n:integer):integer;
begin
if n=0 then gd:=m
else gd:=gd(n,m mod n);
end;
begin
readln(a,b);
write('(',a,',',b,')=');
f:=gd(a,b);
writeln(f)
end.
输入:172 16
输出:(172,16)=4
3.
program exp3;
var
visited:array[1..100] of boolean;
e:array[1..100,1..100] of longint;
n,m,ans,i,j,a,b,c:longint;
procedure dfs(x,len:longint);
var
i:longint;
begin
visited[x]:=true;
if len>ans then ans:=len;
for i:=1 to n do
if (not visited[i]) and (e[x,i]<>-1) then
dfs(i,len+e[x,i]);
visited[x]:=false;
end;
begin
readln(n,m);
for i:=1 to n do
for j:=1 to n do e[i,j]:=-1;
for i:=1 to m do
begin
readln(a,b,c);
e[a,b]:=c;
e[b,a]:=c;
end;
for i:=1 to n do visited[i]:=false;
ans:=0;
for i:=1 to n do dfs(i,0);
writeln(ans);
end.
输入:
4 6
1 2 10
2 3 20
3 4 30
4 1 40
1 3 50
2 4 60
输出:150
4.
program exp4;
var
p,e:array[1..100] of longint;
n,i,m,ans:longint;
function pow(x,w:longint):longint;
var
i,ret:longint;
begin
ret:=1;
for i:=1 to w do
ret:=ret*x;
exit(ret);
end;
begin
readln(n);
m:=0; i:=2;
while n<>1 do
begin
if n mod i = 0 then
begin
inc(m);
p[m]:=i;
e[m]:=0;
while n mod i = 0 do
begin
inc(e[m]);
n:=n div i;
end;
end;
inc(i);
end;
ans:=1;
for i:=1 to m do
ans:=ans*(p[i]-1)*pow(p[i],e[i]-1);
writeln(ans);
end.
输入:19800
输出:4800