1.
program xx2010_1;
var i,j,s:longint;prime:boolean;
begin
for i:=2 to 20 do begin
prime:=true;
for j:=2 to i-1 do
if i mod j=0 then begin
prime:=false;
break;
end;
if prime then s:=s+1;
end;
writeln(s);
end.
输出:8
2.
Program xx2010_2;
var a,b,c,d,n,i,j:longint;find:boolean;
f:array[0..9]of longint;
begin
f[0]:=2;f[1]:=3;f[2]:=5;f[3]:=7;f[4]:=11;
f[5]:=13;f[6]:=17;f[7]:=19;f[8]:=23;f[9]:=29;
readln(a,b,c,d);
n:=10;
a:=((f[a]*f[b]-f[c]*f[d]) mod n+n) mod n;
b:=((f[b]* f[c]-f[d]* f[a]) mod n+n) mod n;
c:=((f[c]* f[d]-f[a]* f[b]) mod n+n) mod n;
d:=((f[d]* f[a]-f[b]* f[c]) mod n+n) mod n;
writeln(a,' ',b,' ',c,' ',d);
end.
【输入】:2 3 5 7
输出:8 4 4 6
3.
Program xx2010_3;
var a:array[1..30]of longint;
s,n,i,x,y,z:longint;c:char;
begin
readln(x,y);
readln(z);
n:=0;
while z>0 do begin
n:=n+1;a[n]:=z mod 10;z:=z div 10;
end;
s:=0;
for i:=n downto 1 do s:=s*x+a[i];
writeln(s);
n:=0;
while s>0 do begin
n:=n+1;a[n]:=s mod y;s:=s div y;
end;
for i:=n downto 1 do write(a[i]);
writeln;
end.
【输入】:
7 2
126
输出:69
1000101
4.
Program xx2010_4;
var f:array[1..46]of longint;
a:array[1..100]of longint;
x,y,z,i,j,n,count:longint;
function find(i,h,x:longint):longint;
var m:longint;
begin
if i<3 then find:=0
else begin
m:=h+f[i-1]-1;
count:=count+1;
if x=a[m] then find:=m
else if x<a[m] then find:=find(i-1,h,x)
else find:=find(i-2,m+1,x);
end;
end;
begin
f[1]:=1;f[2]:=1;
for i:=3 to 46 do f[i]:=f[i-1]+f[i-2];
readln(n,x,y);
for i:=1 to n do a[i]:=3*i-1;
i:=1;
while f[i]-1<n do inc(i);
for j:=n+1 to f[i]-1 do a[j]:=maxlongint;
count:=0;j:=find(i,1,x);
writeln(j,' ',count);
count:=0;j:=find(i,1,y);
writeln(j,' ',count);
end.
【输入】:
8 14 7
输出:5 2
0 4