HOC24
Lớp học
Môn học
Chủ đề / Chương
Bài học
var i:longint; thap:real; nhi:string; begin readln(nhi); thap:=0; for i:=1 to length(nhi) do begin thap:=thap + (ord(nhi[i])-48)* exp(ln(2)*(length(nhi)-i)); end; write(thap:2:0); readln end.
var n,m,i,j,p,q,k,tam:byte; a:array[1..100,1..100] of integer; b:array[1..10000] of integer; f:text; function tong(x,y:integer):integer; var i,j:integer; begin tong:=0; for i:=x to x+p-1 do for j:=y to y+q-1 do tong:=tong+a[i,j]; exit(tong); end; begin assign(f,'HCN.inp');reset(f); readln(f,n,m,p,q); for i:=1 to n do begin for j:=1 to m do read(f,a[i,j]); readln(f); end; close(f); assign(f,'HCN.out');rewrite(f); k:=0; for i:=1 to n-q+1 do begin for j:=1 to m-p+1 do begin inc(k); b[k]:=tong(i,j); end; end; for i:=1 to k-1 do for j:=k downto i+1 do if b[j]>b[j-1] then begin tam:=b[j]; b[j]:=b[j-1]; b[j-1]:=tam; end; writeln(f,b[1]+b[2]); close(f); readln; end.
theo hình vẽ, ra ta thấy \(\overrightarrow{B1}v\text{à}\overrightarrow{B2}\) cùng phương, cùng chiều:
=> \(B_M=B1+B2=2\pi.10^{-7}\frac{\left(I1+I2\right)}{r}=7,5\pi.10^{-6}\left(T\right)\) B1 B2 M I1 I2
var f:text;
s:string;
i,dem,max,dau,cuoi:byte;
begin
assign(f,'xau1.txt'); reset(f);
readln(f,s);
close(f);
assign(f,'xau2.txt'); rewrite(f);
dem:=1; max:=1; dau:=1; cuoi:=1;
for i:=1 to length(s)-1 do
if s[i]=s[i+1] then inc(dem) else dem:=1;
if dem>max then
max:=dem;
cuoi:=i+2;
dau:=cuoi-dem;
end;
write(f,dau,':',cuoi);
readln;
end.
var n,i,dem:longint;
function cp(so:longint):boolean;
if sqr(trunc(sqrt(so)))=so then exit(true)
else exit(false);
function nt(so:longint):boolean;
var k:longint;
if (so=2) or (so=3) then exit(true);
if (so=1) or (so mod 2=0) or (so mod 3=0) then exit(false);
k:=5;
repeat
if (so mod k =0) or (so mod (k+2)=0) then break;
inc(k,6);
until k>trunc(sqrt(so));
exit(k>trunc(sqrt(so)));
write('nhap n:');readln(n);
dem:=0;
for i:=1 to n do
if (cp(i)) and (nt(trunc(sqrt(i)))) then
begin writeln(i); inc(dem); end;
write(dem);
code này chạy khoảng 9s nhé! còn cách tối ưu hơn mong mọi người chỉ bảo!
var n,x,dem:byte;
f:text;
function kt(so:byte):boolean;
var k:byte;
assign(f,'NT.inp');reset(f);
readln(f,n);
assign(f,'NT.out');rewrite(f);
for x:=1 to n div 2 do
if (kt(x)) and (kt(n-x)) then inc(dem);
writeln(f,dem);
readln
chúc bạn học tốt!
Bài 1
Program bai1;
Uses crt;
Var m,n,i,s:longint;
Begin
Clrscr;
Write ('nhap m:'); readln (m);
Write ('nhap n:'); readln (n);
While n <m do
Write ('nhap lai n:');
Readln (n);
End;
S:=0;
For i:=m to n do
If (i mod 3=0) or (i mod 5=0) then s:=s+i;
Write (s);
Readln;
End.