Var A:Array[1..300, 1..300] of longint; m,n,s,i,j: longint; Begin Assign(Input,'ARR2D.INP'); Assign(Output,'ARR2D.OUT'); Reset(Input); Rewrite(Output); Readln(m,n); For i:=1 to m do For j:=1 to n do Read(a[i,j]); S:=0; For i:=1 to m do Begin s:=0; For j:=1 to n do s:=s+a[i,j]; Write(s,#32); End; For j:=1 to n do Begin s:=0; For i:=1 to m do s:=s+a[i,j]; Write(s,#32); End; Close(Input); Close(Output); End.
Var a:array[-5..300,-5..300] of longint; m,n,i,j: longint; Function Nguyento(x: longint): boolean; Var i: longint; Begin If x<2 then exit(false); For i:=2 to trunc(sqrt(x)) do If x mod i = 0 then exit(false); Exit(true); End; Begin Assign(Input,'ARR2DPRI.INP'); Assign(Output,'ARR2DPRI.OUT'); Reset(Input); Rewrite(Output); Readln(m,n); For i:=1 to m do For j:=1 to n do read(a[i,j]); For i:=1 to m do For j:=1 to n do If nguyento(a[i,j]) then writeln(i,#32,j); If not nguyento(a[i,j]) then write('-1'); Close(Input); Close(Output); End.
Var i,j,n: longint; a: array[-7..100007] of longint; Procedure Xuli(); Var i: longint; Begin For i:=1 to n do write(a[i],#32); Writeln; End; Procedure Sinh(); Var i,j: longint; Begin i:=n; While i>0 do Begin i:=n; While a[i]=1 do dec(i); a[i]:=1; For j:=i+1 to n do a[j]:=0; Xuli; End; End; Begin Assign(Input,'SDNP.INP'); Assign(Output,'SDNP.OUT'); Reset(Input); Rewrite(Output); Readln(n); Sinh; Close(Input); Close(Output); End.
Var i,j,n,p: longint; a: array[-7..100007] of longint; Procedure Xuli(); Var i,dem: longint; Begin dem:=0; For i:=1 to n do if a[i]=0 then inc(dem); If 2*dem = n then Begin For i:=1 to n do write(a[i],#32); P:=1; Writeln; End; End; Procedure Sinh(); Var i,j: longint; Begin i:= n; While i>0 do Begin i:= n; While a[i]= 1 do dec(i); a[i]:= 1; For j:= i+1 to n do a[j]:=0; Xuli; End; End; Begin Assign(Input,'SDNP2.INP'); Assign(Output,'SDNP2.OUT'); Reset(Input); Rewrite(Output); Readln(n); p:=0; Sinh; If p=0 then write('-1'); Close(Input); Close(Output); End.
Var i,j,n,p: longint; a: array[-7..100007] of longint; Procedure Xuli(); Var i,dem: longint; Begin P:=1; For i:=1 to n-2 do If a[i]+a[i+1]+a[i+2]=3 then Begin P:=0; Break; End; If p=1 then Begin For i:=1 to n do write(a[i],#32); Writeln; End;
End; Procedure Sinh(); Var i,j: longint; Begin i:= n; While i>0 do Begin i:= n; While a[i]= 1 do dec(i); a[i]:= 1; For j:= i+1 to n do a[j]:=0; Xuli; End; End; Begin Assign(Input,'SDNP3.INP'); Assign(Output,'SDNP3.OUT'); Reset(Input); Rewrite(Output); Readln(n); p:=0; Sinh; If p=0 then write('-1'); Close(Input); Close(Output); End.
Var i,j,n,p,k: longint; a: array[-7..100007] of longint; Procedure Xuli(); Var i,d: longint; Begin P:=1; D:=0; For i:=1 to n do Begin If a[i]=1 then inc(d); If d>k then exit; End; If d<=k then Begin p:=1; For i:=1 to n do write(a[i],#32); Writeln; End; End; Procedure Sinh(); Var i,j: longint; Begin i:= n; While i>0 do Begin i:= n; While a[i]= 1 do dec(i); a[i]:= 1; For j:= i+1 to n do a[j]:=0; Xuli; End; End; Begin Assign(Input,'SDNP4.INP'); Assign(Output,'SDNP4.OUT'); Reset(Input); Rewrite(Output); Readln(n,k); p:=0; Sinh; If p=0 then write('-1'); Close(Input); Close(Output); End.
Var n,p,i: longint; a:array[-7..100007] of longint; Begin Assign(Input,'CBB2.INP'); Assign(Output,'CBB2.OUT'); Reset(Input); Rewrite(Output); Readln(n); P:=1; For i:=1 to n do read(a[i]); For i:=1 to n-1 do If a[i]>a[i+1] then Begin P:=0; Break; End; If P=1 then write('True') Else write('False'); Close(Input); Close(Output); End.
Var a:array[-7..100007] of longint; n,i,t: longint; Begin Assign(Input,'DD.INP'); Assign(Output,'DD.OUT'); Reset(Input); Rewrite(Output); Readln(n); For i:=1 to n do read(a[i]); For i:=1 to n div 2 do Begin t:=a[i]; a[i]:=a[n-i+1]; a[n-i+1]:=t; End; For i:=1 to n do write(a[i],#32); Close(Input); CLose(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Fri Aug 19, 2022 8:42 am
DQBN22
Code:
Var i,j,n: longint; a,b: array[-7..100007] of longint; Function Ngto(x: longint): boolean; Var i: longint; Begin If x<2 then exit(false); For i:=2 to trunc(sqrt(x)) do If x mod i = 0 then exit(false); Exit(True); End; Procedure Xuli(); Var i,s: longint; Begin s:=0; For i:=1 to n do If b[i]=1 then S:=s+a[i]; If Ngto(s)=true then Begin For i:=1 to n do If b[i]=1 then write(a[i],#32); Writeln; End; End; Procedure Sinh(); Var i,j: longint; Begin i:=n; While i>0 do Begin i:=n; While b[i]=1 do dec(i); b[i]:=1; For j:=i+1 to n do b[j]:=0; Xuli; End; End; Begin Assign(Input,'DQBN22.INP'); Assign(Output,'DQBN22.OUT'); Reset(Input); Rewrite(Output); Readln(n); For i:=1 to n do read(a[i]); Sinh(); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Fri Aug 19, 2022 9:06 am
DQBN23
Code:
Uses math; Var i,j,n,res: longint; a,b: array[-7..100007] of longint; Function Ngto(x: longint): boolean; Var i: longint; Begin If x<2 then exit(false); For i:=2 to trunc(sqrt(x)) do If x mod i = 0 then exit(false); Exit(True); End; Procedure Xuli(); Var i,s: longint; Begin S:=0; For i:=1 to n do If b[i]=1 then S:=s+a[i]; If Ngto(s)=true then Res:=max(s,res); End; Procedure Sinh(); Var i,j: longint; Begin i:=n; While i>0 do Begin i:=n; While b[i]=1 do dec(i); b[i]:=1; For j:=i+1 to n do b[j]:=0; Xuli; End; End; Begin Assign(Input,'DQBN23.INP'); Assign(Output,'DQBN23.OUT'); Reset(Input); Rewrite(Output); Readln(n); res:=low(longint); For i:=1 to n do read(a[i]); Sinh(); Write(res); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Fri Aug 19, 2022 9:48 am
EMBERALD
Code:
Uses math; Var i,j,n,res,s: longint; a,b: array[-7..100007] of longint; test:boolean; Procedure Xuli(); Var i,s1,d: longint; Begin d:=0; s1:=0; For i:=1 to n do If b[i]=1 then Begin S1:=S1+a[i]; Inc(d); End; If s1*3=s then Begin Test:=true; Writeln(d); For i:=1 to n do Begin If b[i]=1 then Begin Write(i,#32); End; End;
End; End; Procedure Sinh(); Var i,j: longint; Begin i:=n; While i>0 do Begin I:=n; While b[i]=1 do dec(i); If test=true then exit(); B[i]:=1; For j:=i+1 to n do b[j]:=0; Xuli; End; End; Begin Assign(Input,'EMBERALD.INP'); Assign(Output,'EMBERALD.OUT'); Reset(Input); Rewrite(Output); Test:=false; Readln(n); For i:=1 to n do Begin Read(a[i]); S:=s+a[i]; End; Sinh(); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Fri Aug 19, 2022 10:44 am
BINARY
Code:
Var a: array[-7..100007] of char; n,res: longint; s: string; Procedure Xuli(); Var sa: string; i: longint; Begin Sa:=''; For i:=1 to n do Sa:=sa+a[i]; If pos(s,sa)>0 then inc(res); End; Procedure Sinh(i: longint); Var j: char; Begin For j:='0' to '1' do Begin A[i]:=j; If i=n then Xuli() Else Sinh(i+1); End; End; Begin Assign(Input,'BINARY.INP'); Assign(Output,'BINARY.OUT'); Reset(Input); Rewrite(Output); Readln(n); Readln(s); Res:=0; sinh(1); Write(res); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 8:54 am
Cơ bài bài 1 Day 2
Code:
Var a:array[-7..107,-7..107] of longint; n,m,i,j: longint; Begin Assign(Input,'CBBD2.INP'); Assign(Output,'CBBD2.OUT'); Reset(Input); Rewrite(Output); Readln(m,n); For i:=1 to m do For j:=1 to n do read(a[i,j]); For i:=1 to m do Begin For j:=1 to n do write(a[i,j],#32); Writeln; End; Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 9:17 am
Cơ bài bài 2 Day 2
Code:
Var a: array[-7..107,-7..107] of longint; m,n,i,j,s: longint; Begin Assign(Input,'CBB2D2.INP'); Assign(Output,'CBB2D2.OUT'); Reset(Input); Rewrite(Output); Readln(m,n); s:=0; For i:=1 to m do For j:=1 to n do read(a[i,j]); For i:=1 to m do For j:=1 to n do If a[i,j] mod 2=0 then s:=s+a[i,j]; Write(s); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 9:22 am
Cơ bài bài 3 Day 2
Code:
Var a: array[-7..107,-7..107] of longint; m,n,i,j,s,k:longint; Begin Assign(Input,'CBB3D2.INP'); Assign(Output,'CBB3D2.OUT'); Reset(Input); Rewrite(Output); Readln(m,n,k); s:=0; For i:=1 to m do For j:=1 to n do read(a[i,j]); For i:=1 to m do For j:=1 to n do If a[i,j]=k then inc(s); Write(s); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 9:56 am
Cơ bản bài 5 Day 2
Code:
Var a:array[-7..107,-7..107] of longint; m,n,i,j,res: longint; Begin Assign(Input,'CBB5D2.INP'); Assign(Output,'CBB5D2.OUT'); Reset(Input); Rewrite(Output); Readln(m,n); For i:=1 to m do For j:=1 to n do read(a[i,j]); Res:=a[1,1]; For i:=1 to m do For j:=1 to n do If a[i,j]>res then res:=a[i,j]; Write(res); Close(Input); Close(OUtput); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 10:27 am
Cơ bản bài 6 Day 2
Code:
Var a:array[-7..107,-7..107] of longint; m,n,j,i,s,res: longint; Begin Assign(Input,'CBB6D2.INP'); Assign(Output,'CBB6D2.OUT'); Reset(Input); Rewrite(Output); ReadlN(m,n); s:=0; For i:=1 to m do For j:=1 to n do read(a[i,j]); Res:=a[1,1]; For i:=1 to m do For j:=1 to n do If a[i,j]>res then res:=a[i,j]; For i:=1 to m do For j:=1 to n do If a[i,j]=res then inc(s); Write(res,#32,s); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 10:27 am
Cơ bài bài 7 Day 2
Code:
Var a:array[-7..107,-7..107] of longint; m,n,j,i,s,res: longint; Begin Assign(Input,'CBB7D2.INP'); Assign(Output,'CBB7D2.OUT'); Reset(Input); Rewrite(Output); ReadlN(m,n); s:=0; For i:=1 to m do For j:=1 to n do read(a[i,j]); Res:=a[1,1]; For i:=1 to m do For j:=1 to n do If a[i,j]<res then res:=a[i,j]; For i:=1 to m do For j:=1 to n do If a[i,j]=res then inc(s); Write(res,#32,s); Close(Input); Close(Output); End.
TrannQuanggDatt2008
Tổng số bài gửi : 70 Join date : 16/06/2022
Tiêu đề: Re: Trần Quang Đạt Mon Aug 22, 2022 10:28 am
Cơ bài bài 8 Day 2
Code:
Var a:array[-7..107,-7..107] of longint; m,n,i,j,rmax: longint; Begin Assign(Input,'CBB8D2.INP'); Assign(Output,'CBB8D2.OUT'); Reset(Input); Rewrite(Output); Readln(m,n); For i:=1 to m do For j:=1 to n do read(a[i,j]); For i:=1 to m do Begin Rmax:=a[i,1]; For j:=1 to n do If rmax<a[i,j] then rmax:=a[i,j]; Write(rmax,#32); End; Close(Input); Close(Output); End.
Var s1,s: string; Function Demsl(a,b: string): longint; Var d,p: longint; Begin d:=0; While Pos(b,a)>0 do Begin P:=Pos(b,a); Inc(d); Delete(a,1,p); End; Exit(d); End; Begin Assign(Input,'D1XB3.INP'); Assign(Output,'D1XB3.OUT'); Reset(Input); Rewrite(Output); Readln(s1); Readln(s); Write(Demsl(s,s1)); Close(Input); Close(Output); End.
Var s: string; Function Demkitu(s: string): longint; Var i,d: longint; Begin d:=0; For i:=1 to length(s) do If (s[i]>='0') and (s[i]<='9') then inc(d); Exit(d); End; Begin Assign(Input,'D1XB5.INP'); Assign(Output,'D1XB5.OUT'); Reset(Input); Rewrite(Output); Readln(s); Write(Demkitu(s)); Close(Input); Close(Output); End.
Var s,tam: string; c: array[-7..10007] of longint; i,n,k: longint; Begin Assign(Input,'D2XB1.INP'); Assign(Output,'D2XB1.OUT'); Reset(Input); Rewrite(Output); Readln(s); tam:=''; For i:=1 to length(s) do If (s[i]>='0') and (s[i]<='9') then tam:=tam+s[i] Else If length(tam)>0 then Begin Val(tam,n); Inc(k); C[k]:=n; Tam:=''; End; For i:=1 to k do write(c[i],#32); Close(Input); Close(Output); End.
Var s,tam: string; c: array[-7..10007] of longint; i,n,k,max: longint; Begin Assign(Input,'D2XB2.1.INP'); Assign(Output,'D2XB2.1.OUT'); Reset(Input); Rewrite(Output); Readln(s); tam:=''; For i:=1 to length(s) do If (s[i]>='0') and (s[i]<='9') then tam:=tam+s[i] Else If length(tam)>0 then Begin Val(tam,n); Inc(k); C[k]:=n; Tam:=''; End; Max:=C[1]; For i:=1 to k do If c[i]>max then max:=c[i]; Write(c[i]); Close(Input); Close(Output); End.