1.
Program cz2010_1;
var a,b,c,d,n,i,j:longint;
find:boolean;
f:array[0..19]of longint;
begin
n:=-1;i:=1;
while n<19 do begin
i:=i+1;find:=false;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then begin
find:=true;break;
end;
if not find then begin
n:=n+1;f[n]:=i;
end;
end;
readln(a,b,c,d);
n:=n+1;
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 14 6 18
2.
Program cz2010_2;
var a:array[1..30]of char;
s,n,i,x,y,z:longint;c:char;
begin
s:=0;readln(x,y);
while not eoln do begin
read(c);
if c<='9' then s:=s*x+ord(c)-ord('0')
else s:=s*x+ord(c)-ord('A')+10;
end;
readln;write(s,’ ‘); n:=0;
while s>0 do begin
n:=n+1;z:=s mod y;
if z>9 then a[n]:=chr(z-10+ord('A'))
else a[n]:=chr(z+ord('0'));
s:=s div y;
end;
for i:=n downto 1 do write(a[i]);
writeln;
end.
【输入1】:
7 2
126
【输入2】:
16 13
3A2B
输出:69 1000101|14891 6A16
3.
Program cz2010_3;
var fu,a,num,b,tot,k,n:longint;
shu:boolean;c:char;
begin
num:=0;a:=0;fu:=1;shu:=false;b:=0;
while not(eoln) do begin //当一行输入未结束时
read(c);
if c='-' then fu:=-1
else if (c<='9') and (c>='0') then begin
val(c,k); num:=10*num+k; shu:=true; end;
else if shu then begin
shu:=false;
if (fu=1) and (num>0) then inc(a);
if fu=-1 then inc(b);
inc(tot,num*fu);
inc(n);num:=0;fu:=1;
end;
end;
if shu then begin
shu:=false;
if (fu=1) and (num>0) then inc(a);
if fu=-1 then inc(b);
inc(n); inc(tot,num*fu);
num:=0;fu:=1;
end;
writeln(tot/n:0:3,' ',a,' ',b);
close(input);close(output);
end.
【输入】
54hiy-24 51
输出:27.000 2 1
4.
Program cz2010_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 exit(0);
m:=h+f[i-1]-1; count:=count+1;
if x=a[m] then exit(m);
if x<a[m] then exit(find(i-1,h,x))
else exit(find(i-2,m+1,x));
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,z);
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); count:=0;
j:=find(i,1,z); writeln(j,' ',count);
end.
【输入】
8 14 7 17
输出:5 2
0 4
6 4