Đáp án đề thi chọn đội tuyển tham dự kì thi chọn HSG Tỉnh năm 2010 - 2011

4 336 0
Đáp án đề thi chọn đội tuyển tham dự kì thi chọn HSG Tỉnh năm 2010 - 2011

Đang tải... (xem toàn văn)

Thông tin tài liệu

BAI 1: CONST input ='LK3.INP'; output='LK3.OUT'; TYPE mang=array[1 100] of integer; VAR f1,f2:text; a,b: mang; i,j,n,h,l,c,dem,k: integer; FUNCTION snt(n:integer):boolean; Var kt: boolean; i,d: integer; Begin if n<2 then kt:= false; if (n=2)or(n=3) then kt:= true; if n>3 then begin d:= 0; for i:= 2 to n div 2 do begin if n mod i=0 then d:= d+1; break; end; if d=0 then kt:= true else kt:= false; end; snt:= kt; End; BEGIN assign(f1,input); assign(f2,output); reset(f1); rewrite(f2); readln(f1,n); for i:= 1 to n do begin read(f1,a[i]); end; dem:= 0; for i:= 1 to n do begin if snt(a[i])=true then begin dem:= dem+1; end; end; writeln(' day so tren co ',dem,' so nguyen to '); writeln('============ '); writeln(f2,'day so tren co ',dem,' so nguyen to '); writeln(f2,'=========='); i:= 1; while i<n do begin if a[i]<a[i+1] then begin j:= i; l:= 1; while (j<n)and(a[j]<a[j+1]) do begin b[l]:= a[j]; j:= j+1; l:= l+1; end; if a[j]>=a[j+1] then i:= j+1; b[l]:= a[j]; h:= 1; while h<=l do begin if snt(b[h])= true then begin k:= h; c:=0; while (k<l)and(snt(b[k+1])=true) do begin write(b[k]:3); write(f2,b[k]:3); k:= k+1; c:= c+1; end; if (c>=1)and(snt(b[k+1])=false) then begin write(b[k]:3); write(f2,b[k]:3); end; h:= k+1; end else h:= h+1; end; writeln; writeln(f2); end else i:= i+1; end; close(f1); close(f2); readln; END. BAI 2: program diemyenngua_Yen; const input='YN4.INP'; output='YN4.OUT'; var a: array[1 100,1 100] of integer; min,max,i,j,x,t,d,c,dem: integer; f1,f2:text; begin assign(f1,input); assign(f2,output); reset(f1); rewrite(f2); read(f1,d,c); readln(f1); for i:= 1 to d do begin for j:= 1 to c do begin read(f1,a[i,j]); end; readln(f1); end; close(f1); {=================================================================} dem:=0; for i:=1 to d do begin max:=a[i,1]; x:=1; for j:=1 to c do begin if a[i,j]>max then begin max:=a[i,j]; x:=j; end; end; min:=a[1,x]; for t:=1 to d do if min> a[t,x] then min:=a[t,x]; if min=max then begin dem:=dem+1; write(min:5); write(f2,min:5);end; end; {==================================================================} for i:=1 to d do begin min:=a[i,1]; x:=1; for j:=1 to c do begin if a[i,j]<min then begin min:=a[i,j]; x:=j; end; end; max:=a[1,x]; for t:=1 to d do if max< a[t,x] then max:=a[t,x]; if min=max then begin dem:=dem+1; write(min:5);write(f2,min:5); end; end; if dem=0 then write('khong co diem yen ngua'); write(f2,' khong co diem yen ngua '); readln end. BAI 3: program phantichso; const input='PT4.INP'; output='PT4.OUT'; var n,i,j: integer; f1,f2: text; function snt(b:integer): boolean; var i,d: integer; kt: boolean; begin kt:=true; if b<=1 then kt:=false; if (b=2) or (b=3) then kt:=true; d:=0; if b>=4 then begin for i:=2 to b div 2 do if b mod i=0 then d:=d+1; if d=0 then kt:=true else kt:=false; end; snt:=kt; end; begin {write(' n= ');readln(n); } assign(f1,input); assign(f2,output); reset(f1); rewrite(f2); read(f1,n); close(f1); if snt(n)=true then begin write('SNT'); write(f2,' SNT'); end else begin writeln('HS'); writeln(f2,'HS'); end; if snt(n)=false then begin for i:=1 to n-1 do begin for j:=n downto i do begin if(snt(i)=true)and(snt(j)=true)and(i+j=n)then begin writeln(i,j:5); write(f2,i,j:5); end; end; end; end; close(f2); readln end. ?? ?? ?? ?? 3 . writeln('HS'); writeln(f2,'HS'); end; if snt(n)=false then begin for i:=1 to n-1 do begin for j:=n downto i do begin if(snt(i)=true)and(snt(j)=true)and(i+j=n)then begin

Ngày đăng: 14/06/2015, 20:00

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan