Bài thi oplympic 11 (08-09)
2 posters
Trang 1 trong tổng số 1 trang
Bài thi oplympic 11 (08-09)
Bài 1: nè
program b99e;
const co=100;
nmax=10;
input='b99e.inp';
output='b99e.out';
type kieu=integer;
solon=array[-2..co] of kieu;
var a:solon;
k,b,e:integer;
fi,fo:text;
{function lonbang(x,y:solon):boolean;
var i:kieu;
begin
if x[-1]>y[-1] then lonbang:=true
else if x[-1] else
begin
i:=x[-1];
while (x[i]=y[i]) and (i>-1) do dec(i);
if x[i]>y[i] then lonbang:=true
else lonbang:=false;
if i=-1 then lonbang:=true;
end;
end;
procedure scs(var a:solon);
var i:kieu;
begin
for i:=co downto 1 do
if a[i]<>0 then
begin
a[-1]:=i;
exit;
end;
end;
procedure tru(x,y:solon;var h:solon);
var i,phu,nho:kieu;
begin
if lonbang(x,y) then
begin
h[-1]:=x[-1];
end
else
begin
h[-2]:=-1;
tru(y,x,h);
end;
nho:=0;
for i:=1 to h[-1] do
begin
phu:=x[i]-y[i]-nho;
h[i]:=phu;
if phu<0 then
begin
h[i]:=10+phu;
nho:=1;
end
else nho:=0;
end;
scs(h);
end; }
procedure print(a:solon);
var i:kieu;
begin
for i:=a[-1] downto 1 do
write(fo,a[i]);
writeln(fo);
end;
{
procedure cong(x,y:solon;var tong:solon);
var i,nho,phu:kieu;
begin
if lonbang(x,y) then tong[-1]:=x[-1]
else tong[-1]:=y[-1];
nho:=0;
for i:=1 to tong[-1] do
begin
phu:=x[i]+y[i]+nho;
tong[i]:=phu mod 10;
nho:=phu div 10;
end;
if nho>0 then
begin
inc(tong[-1]);
tong[tong[-1]]:=nho;
end;
end;
procedure tang(var a:solon);
var phu,nho,i:kieu;
begin
nho:=1;
i:=1;
while nho<>0 do
begin
a[i]:=a[i]+1;
if a[i]=10 then
begin
a[i]:=0;
nho:=1;
inc(i);
end
else nho:=0;
end;
if i>a[-1] then inc(a[-1]);
end;
procedure chia(x,y:solon;var t,du:solon);
begin
fillchar(t,sizeof(t),0);
fillchar(du,sizeof(du),0);
while lonbang(x,y) do
begin
tang(t);
tru(x,y,x);
end;
du:=x;
end;
procedure tim;
var lt:qword;
k:word;
thuong,du:solon;
sc,t:solon;
begin
fillchar(a,sizeof(a),0);
a[-1]:=1;
t[-1]:=3;t[1]:=e;t[2]:=0;t[3]:=b;
tam:=t;
sc[-1]:=2;sc[1]:=9;sc[2]:=8;
pc:=sc;
while t[-1]<=50 do
begin
chia(tam,sc,thuong,du);
if du[1]=0 then
begin
cong(a,thuong,a);
exit;
end;
a[a[-1]]:=0;
inc(a[-1]);
a[a[-1]]:=1;
inc(pc[-1]);
for k:=pc[-1] downto 2 do
pc[k]:=pc[k-1];
pc[1]:=0;
t[t[-1]]:=0;
inc(t[-1]);
t[t[-1]]:=b;
tru(t,pc,tam);
end;
a[1]:=0;a[-1]:=1;
end;}
procedure tim;
var nho,phu,nho1:integer;
stop:boolean;
begin
fillchar(a,sizeof(a),0);
a[1]:=10-e;
k:=1;
nho:=1;
phu:=0;
stop:=false;
if ((a[k]+nho)mod 10=a[k-1]) and (b+nho=a[k]) then stop:=true
else stop:=false;
while not(stop) and (k<=50) do
begin
inc(k);
phu:=a[k-2]-nho;
a[k]:=phu-a[k-1];
if a[k]<0 then
begin
a[k]:=10+a[k];
nho:=1;
end
else nho:=0;
if (a[k]+nho) mod 10=a[k-1] then
begin
if a[k]+nho=10 then
nho1:=1 else nho1:=0;
if b+nho1=a[k] then
stop:=true;
end;
end;
a[-1]:=k;
if k>50 then
begin
a[-1]:=1;
a[1]:=0;
end;
end;
begin
assign(fi,input);
reset(fi);
assign(fo,output);
rewrite(fo);
while not eof(fi) do
begin
readln(fi,b,e);
tim;
print(a);
end;
close(fo);
close(fi);
end.
program b99e;
const co=100;
nmax=10;
input='b99e.inp';
output='b99e.out';
type kieu=integer;
solon=array[-2..co] of kieu;
var a:solon;
k,b,e:integer;
fi,fo:text;
{function lonbang(x,y:solon):boolean;
var i:kieu;
begin
if x[-1]>y[-1] then lonbang:=true
else if x[-1]
begin
i:=x[-1];
while (x[i]=y[i]) and (i>-1) do dec(i);
if x[i]>y[i] then lonbang:=true
else lonbang:=false;
if i=-1 then lonbang:=true;
end;
end;
procedure scs(var a:solon);
var i:kieu;
begin
for i:=co downto 1 do
if a[i]<>0 then
begin
a[-1]:=i;
exit;
end;
end;
procedure tru(x,y:solon;var h:solon);
var i,phu,nho:kieu;
begin
if lonbang(x,y) then
begin
h[-1]:=x[-1];
end
else
begin
h[-2]:=-1;
tru(y,x,h);
end;
nho:=0;
for i:=1 to h[-1] do
begin
phu:=x[i]-y[i]-nho;
h[i]:=phu;
if phu<0 then
begin
h[i]:=10+phu;
nho:=1;
end
else nho:=0;
end;
scs(h);
end; }
procedure print(a:solon);
var i:kieu;
begin
for i:=a[-1] downto 1 do
write(fo,a[i]);
writeln(fo);
end;
{
procedure cong(x,y:solon;var tong:solon);
var i,nho,phu:kieu;
begin
if lonbang(x,y) then tong[-1]:=x[-1]
else tong[-1]:=y[-1];
nho:=0;
for i:=1 to tong[-1] do
begin
phu:=x[i]+y[i]+nho;
tong[i]:=phu mod 10;
nho:=phu div 10;
end;
if nho>0 then
begin
inc(tong[-1]);
tong[tong[-1]]:=nho;
end;
end;
procedure tang(var a:solon);
var phu,nho,i:kieu;
begin
nho:=1;
i:=1;
while nho<>0 do
begin
a[i]:=a[i]+1;
if a[i]=10 then
begin
a[i]:=0;
nho:=1;
inc(i);
end
else nho:=0;
end;
if i>a[-1] then inc(a[-1]);
end;
procedure chia(x,y:solon;var t,du:solon);
begin
fillchar(t,sizeof(t),0);
fillchar(du,sizeof(du),0);
while lonbang(x,y) do
begin
tang(t);
tru(x,y,x);
end;
du:=x;
end;
procedure tim;
var lt:qword;
k:word;
thuong,du:solon;
sc,t:solon;
begin
fillchar(a,sizeof(a),0);
a[-1]:=1;
t[-1]:=3;t[1]:=e;t[2]:=0;t[3]:=b;
tam:=t;
sc[-1]:=2;sc[1]:=9;sc[2]:=8;
pc:=sc;
while t[-1]<=50 do
begin
chia(tam,sc,thuong,du);
if du[1]=0 then
begin
cong(a,thuong,a);
exit;
end;
a[a[-1]]:=0;
inc(a[-1]);
a[a[-1]]:=1;
inc(pc[-1]);
for k:=pc[-1] downto 2 do
pc[k]:=pc[k-1];
pc[1]:=0;
t[t[-1]]:=0;
inc(t[-1]);
t[t[-1]]:=b;
tru(t,pc,tam);
end;
a[1]:=0;a[-1]:=1;
end;}
procedure tim;
var nho,phu,nho1:integer;
stop:boolean;
begin
fillchar(a,sizeof(a),0);
a[1]:=10-e;
k:=1;
nho:=1;
phu:=0;
stop:=false;
if ((a[k]+nho)mod 10=a[k-1]) and (b+nho=a[k]) then stop:=true
else stop:=false;
while not(stop) and (k<=50) do
begin
inc(k);
phu:=a[k-2]-nho;
a[k]:=phu-a[k-1];
if a[k]<0 then
begin
a[k]:=10+a[k];
nho:=1;
end
else nho:=0;
if (a[k]+nho) mod 10=a[k-1] then
begin
if a[k]+nho=10 then
nho1:=1 else nho1:=0;
if b+nho1=a[k] then
stop:=true;
end;
end;
a[-1]:=k;
if k>50 then
begin
a[-1]:=1;
a[1]:=0;
end;
end;
begin
assign(fi,input);
reset(fi);
assign(fo,output);
rewrite(fo);
while not eof(fi) do
begin
readln(fi,b,e);
tim;
print(a);
end;
close(fo);
close(fi);
end.
strawhero- Admin
-
Tổng số bài gửi : 1752
Birthday : 01/02/1992
Age : 32
Đến từ : ??
Job/hobbies : game
Họ và tên : Hồ Quốc Vương
số dt : 01222483486
yahoo : strawherotk
thanks : 12
Registration date : 15/08/2008
Re: Bài thi oplympic 11 (08-09)
b99e.inp
1 5
1 8
3 8
8 4
8 1
1 5
1 8
3 8
8 4
8 1
strawhero- Admin
-
Tổng số bài gửi : 1752
Birthday : 01/02/1992
Age : 32
Đến từ : ??
Job/hobbies : game
Họ và tên : Hồ Quốc Vương
số dt : 01222483486
yahoo : strawherotk
thanks : 12
Registration date : 15/08/2008
Re: Bài thi oplympic 11 (08-09)
112359550561797752808988764045
11235955056179775280898876404494382022472
0
89887640449438202247191011236
9
11235955056179775280898876404494382022472
0
89887640449438202247191011236
9
strawhero- Admin
-
Tổng số bài gửi : 1752
Birthday : 01/02/1992
Age : 32
Đến từ : ??
Job/hobbies : game
Họ và tên : Hồ Quốc Vương
số dt : 01222483486
yahoo : strawherotk
thanks : 12
Registration date : 15/08/2008
Re: Bài thi oplympic 11 (08-09)
Bài này không khó lắm. Chỉ vì cứ nghĩ mãi theo cách cũ nên làm không ra.
Nếu N nhỏ thì có thể dùng cách cũ (cách chia cho 89) sẽ đơn giản.
Nhưung nếu N lơn thì phải dùng cách trên.
Nếu N nhỏ thì có thể dùng cách cũ (cách chia cho 89) sẽ đơn giản.
Nhưung nếu N lơn thì phải dùng cách trên.
strawhero- Admin
-
Tổng số bài gửi : 1752
Birthday : 01/02/1992
Age : 32
Đến từ : ??
Job/hobbies : game
Họ và tên : Hồ Quốc Vương
số dt : 01222483486
yahoo : strawherotk
thanks : 12
Registration date : 15/08/2008
Re: Bài thi oplympic 11 (08-09)
hồi thi đọc zô thì làm ,cái bài olympic chừ mới đem ra giải ,mày hok có chuyện chi làm hả !!!
Re: Bài thi oplympic 11 (08-09)
sặc. Chừ mới nghĩ ra cách giải. Mi tưởng dễ lắm hả
strawhero- Admin
-
Tổng số bài gửi : 1752
Birthday : 01/02/1992
Age : 32
Đến từ : ??
Job/hobbies : game
Họ và tên : Hồ Quốc Vương
số dt : 01222483486
yahoo : strawherotk
thanks : 12
Registration date : 15/08/2008
Re: Bài thi oplympic 11 (08-09)
Sặc! ngu vkl.
Cách ni ta mới nghĩ ra. Sao biết mà giải.
Hồi thi dùng cách cũ. Nếu đọc kĩ đề thì cũng đựơc 40%.
Cách ni ta mới nghĩ ra. Sao biết mà giải.
Hồi thi dùng cách cũ. Nếu đọc kĩ đề thì cũng đựơc 40%.
strawhero- Admin
-
Tổng số bài gửi : 1752
Birthday : 01/02/1992
Age : 32
Đến từ : ??
Job/hobbies : game
Họ và tên : Hồ Quốc Vương
số dt : 01222483486
yahoo : strawherotk
thanks : 12
Registration date : 15/08/2008
Trang 1 trong tổng số 1 trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|