noip2008复赛答案 (普及组)

2024-12-16 15:58:30
推荐回答(1个)
回答1:

第一题
Program Gy;
Const
Name='isbn';
Var
A,B:String;

Procedure Inp;
Begin
Assign(Input,Name+'.in');Reset(Input);
Assign(Output,Name+'.out');Rewrite(Output);
Readln(A);
End;

Procedure Main;
Var i,j,k:Longint;
Begin
j:=0;k:=0;
For i:=1 to Length(A)-1 do
If A[i]in['0'..'9']then
Begin
Inc(k);
j:=j+(Ord(A[i])-Ord('0'))*k;
End;
j:=j mod 11;
B:=A;
If j=10 then B[Length(B)]:='X'Else B[Length(B)]:=Chr(j+Ord('0'));
End;

Procedure Oup;
Begin
If B=A then Writeln('Right')
Else Writeln(B);
Close(Input);
Close(Output);
End;

Begin
Inp;
Main;
Oup;
End.
第二题
Program Gy;
Uses Math;
Const
Name='seat';
Var
x1,y1,x2,y2:Array[1..3000]of Longint;
N,M,K,L,D:longint;
A,C:Array[1..2,1..2000]of Longint;
B1,B2:Array[1..2000]of Byte;

Procedure Inp;
Var i:longint;
Begin
Assign(Input,Name+'.in');Reset(Input);
Assign(Output,Name+'.out');Rewrite(Output);
Randomize;
Readln(M,N,K,L,D);
For i:=1 to D do Readln(x1[i],y1[i],x2[i],y2[i]);
End;

Procedure Sort(p,l,r:Longint);
Var i,j,x,y:Longint;
Begin
i:=l;j:=r;x:=a[p,Random(r-l)+l];
Repeat
While a[p,i]>x do Inc(i);
While a[p,j]If i<=j then
Begin
y:=a[p,i];
a[p,i]:=a[p,j];
a[p,j]:=y;
y:=c[p,i];
c[p,i]:=c[p,j];
c[p,j]:=y;Inc(i);
Dec(j);
End;
Until i>j;
If lIf iEnd;

Procedure Main;
Var i:Longint;
Begin
For i:=1 to M do C[1,i]:=i;
For i:=1 to N do C[2,i]:=i;
For i:=1 to d do
If x1[i]=x2[i]then Inc(A[2,Min(y1[i],y2[i])])
Else Inc(A[1,Min(x1[i],x2[i])]);
Sort(1,1,N);
Sort(2,1,M);
For i:=1 to K do B1[C[1,i]]:=1;
For i:=1 to L do B2[C[2,i]]:=1;
End;

Procedure Oup;
Var i,j:Longint;
Begin
j:=0;

For i:=1 to M-1 do
If b1[i]=1 then
Begin
Inc(j);
Write(i);
If j<>K then Write(' ');
End;
Writeln;
j:=0;
For i:=1 to N-1 do
If b2[i]=1 then
Begin
Inc(j);
Write(i);
If j<>L then Write(' ');
End;
Writeln;
Close(Input);
Close(Output);
End;

Begin
Inp;
Main;
Oup;
End.
第三题
Program Gy;
Uses Math;
Const
Name='ball';
Var
F:Array[0..1,1..500]of Longint;
M,N:Longint;

Procedure Inp;
Begin
Assign(Input,Name+'.in');Reset(Input);
Assign(Output,Name+'.out');Rewrite(Output);
Readln(n,m);
End;

Procedure Main;
Var i,j:Longint;
Begin
F[0,1]:=1;
For i:=1 to M do
For j:=1 to N do
F[i mod 2,j]:=F[(i-1)mod 2,(j+n-2)mod n+1]+F[(i-1)mod 2,(j+n)mod n+1];
End;

Procedure Oup;
Begin
Writeln(F[M mod 2,1]);
Close(Input);
Close(Output);
End;

Begin
Inp;
Main;
Oup;
End.
第四题
Program Gy;
Const
Work='drawing';
Type
Rec=Record
X,Y:longint;
End;
Arr=Array[1..20000] of Longint;
Var
A:Array[1..300,1..300] of Longint;
N,M,MaxN,MaxM:Longint;
B:Array[1..1000,1..1000]of Char;
Procedure Inp;
Var i,j:Longint;
Begin
Assign(Input,Work+'.in');Reset(Input);
Assign(Output,Work+'.out');Rewrite(Output);
Read(n,m);
For i:=1 to N do
For j:=1 to M do
Read(a[n+1-i,j]);
MaxN:=0;MaxM:=0;
For i:=1 to N do
For j:=1 to M do
Begin
If 2*i+4*j+1>MaxM then MaxM:=2*i+4*j+1;
If (2*i+3*a[i,j]+1>MaxN) then Maxn:=2*i+3*a[i,j]+1;
End;
For i:=1 to MaxN do
For j:=1 to MaxM do
B[i,j]:='.';
End;

Procedure Main;
Var i,j,k,x,y:Longint;
Begin
For i:=N downto 1 do
For j:=1 to M do
For k:=1 to A[i,j] do
Begin
Y:=2*i+4*j-5;X:=2*i+3*k-4;
B[x,y]:='+';
B[x,y+1]:='-';
B[x,y+2]:='-';
B[x,y+3]:='-';
B[x,y+4]:='+';
B[x+1,y]:='|';
B[x+1,y+1]:=' ';
B[x+1,y+2]:=' ';
B[x+1,y+3]:=' ';
B[x+1,y+4]:='|';
B[x+1,y+5]:='/';
B[x+2,y]:='|';
B[x+2,y+1]:=' ';
B[x+2,y+2]:=' ';
B[x+2,y+3]:=' ';
B[x+2,y+4]:='|';
B[x+2,y+5]:=' ';
B[x+2,y+6]:='+';
B[x+3,y]:='+';
B[x+3,y+1]:='-';
B[x+3,y+2]:='-';
B[x+3,y+3]:='-';
B[x+3,y+4]:='+';
B[x+3,y+5]:=' ';
B[x+3,y+6]:='|';
B[x+4,y+1]:='/';
B[x+4,y+2]:=' ';
B[x+4,y+3]:=' ';
B[x+4,y+4]:=' ';
B[x+4,y+5]:='/';
B[x+4,y+6]:='|';
B[x+5,y+2]:='+';
B[x+5,y+3]:='-';
B[x+5,y+4]:='-';
B[x+5,y+5]:='-';
B[x+5,y+6]:='+';
End;
End;

Procedure Oup;
Var i,j:Longint;
Begin
For i:=MaxN downto 1 do
Begin
For j:=1 to MaxM do
Write(b[i,j]);
Writeln;
End;
Close(Input);
Close(Output);
End;

Begin
Inp;
Main;
Oup;
End.
测过全对(逐字节)