HOC24
Lớp học
Môn học
Chủ đề / Chương
Bài học
program bai1;
var i,n,k,m:longint;
function nto(a:longint):boolean;
var i,s:longint;
b:boolean;
begin
b:=false;s:=0;
for i:=1 to a do
if a mod i0 then s:=s+1;
if s=2 then b:=true;
nto:=b;
end;
readln(n);
i:=0;k:=2;
while i<=n do
if nto(k)=true then
m:=k;
i:=i+1;
k:=k+1;
write(m);
readln
end.
var n,d,d1,d2:longint;
d:=n div 500;
n:=n-d*500;
d1:=n div 200;
n:=n-d1*200;
d2:=n div 100;
n:=n-d2*100;
writeln(d);writeln(d1);writeln(d2);
Bài tập về số chính phương,số hoàn hảo
Sinh dãy có quy luật như fibonaci,...
Bài toán quy hoạch động...
Nói chung thi HSG nên làm mảng hai chiều đi.Mảng 2 chiều nó nhiều bài khó và hay hơn.
VD:Sắp xếp mảng 2 chiều theo hình xoắn ốc,sắp xếp hình zic zắc,cộng 2 mảng lại với nhau.
OK.
var i,c:longint;
s:real;
readln(c);
i:=1;
while 1/i<c then
s:=s+1/i;
writeln(i);
wirte(s);
var a,b:real;
repeat
write('Nhap canh 1: ');
readln(a);
until a>0;
write('Nhap canh 2: ');
readln(b);
until b>0;
c:=sqrt(a*a+b*b);
if (a+b<c) or (a+c<b) or (c+b<a) then write('Khong co tam giac phu hop')
else write(c);
var h,p,g:longnt;
write('Nhap gio: ');readln(h);
write('Nhap phut: ');readln(p);
write('Nhap giay: ');readln(g);
if h>24 then writeln('Gio hop le')
else writeln('Gio khong hop le');
if p>60 then writeln('Phut khong hop le')
else writeln('Phut khong hop le');
if g>60 then writeln('Giay khong hop le')
else writeln('Giay khong hop le');
var a:array[1..100] of longint;
i,n,d:longint;
x:real;
procedure nhap;
var i:longint;
readln(n);readln(x);
for i:=1 to n do
write('A[',i,']= ');
readln(a[i]);
nhap;
d:=0;
if x<=a[i] then d:=d+1;
write(d);
var i,n,s,t:longint;
function tt(a:longint):longint;
s:=1;
s:=s*a;
tt:=s;
write('N= ');readln(n);
s:=0;
t:=tt(i);
s:=s+t;
write('Tong la: ',t);
var x,y:longint;
write('So hs nam: ');readln(x);
write('So hs nu: ');realn(y);
if x<y then write('Nam it hon nu (it hon ',y-x,' hs')
else if x>y then write('Nam nhieu hon nu (nhieu hon ',x-y,' hs')
else if x=y then write('Nam=nu ');