Những câu hỏi liên quan
APOK FF
Xem chi tiết
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
4 tháng 4 2022 lúc 21:49

#include <bits/stdc++.h>

using namespace std;

long long a[1000],n,i;

int main()

{

freopen("dayd.inp","r",stdin);

freopen("dayd.out","w",stdout);

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

for (i=1; i<=n; i++)

if (a[i]>0) cout<<a[i]<<" ";

return 0;

}

Bình luận (0)
huynh chinh
Xem chi tiết
Nguyễn Lê Phước Thịnh
31 tháng 3 2022 lúc 22:48

#include <bits/stdc++.h>

using namespace std;

long long a[10000],i,n,t;

int main()

{

freopen("avg.inp","r",stdin);

freopen("avg.out","w",stdout);

cin>>n;

for (i=1; i<=n; i++) cin>>a[i];

t=0;

for (i=1; i<=n; i++) t+=a[i];

cout<<fixed<<setprecision(1)<<(t*1.0)/(n*1.0);

return 0;

}

Bình luận (0)
Noelle
Xem chi tiết
Nguyễn Lê Phước Thịnh
23 tháng 3 2021 lúc 20:11

const fi='divk.inp'

fo='divk.out'

var f1,f2:text;

a:array[1..100]of integer;

i,n,k,dem,j,x,t:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n,k);

for i:=1 to n do 

  read(f1,a[i]);

dem:=0;

for i:=1 to n do 

  for j:=1 to n do 

begin

if i<j then 

begin

t:=0;

for x:=i to j do 

  t:=t+a[x];

if t=k then inc(dem);

end;

for i:=1 to n do 

  if k=a[i] then inc(dem);

writeln(f2,dem);

close(f1);

close(f2);

end.

Bình luận (0)
trung kien ta
15 tháng 10 2022 lúc 14:59

#include <bits/stdc++.h>
using namespace std;
#define nhungcute ios_base::sync_with_stdio; cin.tie(0); cout.tie(0);
const int N=1500;
long long n,k,a[N],i,j,c[N][101];
int main(){
nhungcute
    cin>>n>>k;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++){
        a[i]=a[i]%k;
    }
    for(i=1;i<k;i++)
    c[1][i] =-1e9;
    c[1][a[0]]=0;
    c[1][a[1]]=1;
    for(i=2;i<=n;i++){
        for(j=0;j<k;j++){
        c[i][j]=max(c[i-1][j],c[i-1][(j-a[i]+k)%k]+1);
        }
    }
    cout<<c[n][0];
    return 0;
}

 

Bình luận (0)
thiên thanh
Xem chi tiết
ngo minh duc
Xem chi tiết
Nguyễn Lê Phước Thịnh
21 tháng 3 2021 lúc 9:26

Câu 7:

const fi='dayso.inp'

fo='dayso.out'

var f1,f2:text;

a,b:array[1..100]of integer;

i,n,dem,j,t,kt,dem1:integer;

begin

assign(f1,fi); reset(f1);

assign(f2,fo); rewrite(f2);

readln(f1,n);

for i:=1 to n do 

  read(f1,a[i]);

t:=0;

for i:=1 to n do 

  t:=t+a[i];

writeln(f2,'Tong cua day so la: ',t);

b[1]:=a[1];

dem:=1;

for i:=1 to n do 

  begin

kt:=0;

for j:=1 to dem do 

  if a[i]=b[j] then kt:=1;

if kt=0 then

begin

inc(dem);

b[dem]:=a[i];

end;

end;

for i:=1 to dem do 

  begin

dem1:=0;

for j:=1 to n do 

  if b[i]=a[j] then inc(dem1);

writeln(f2,b[i],' xuat hien ',dem1,' lan');

close(f1);

close(f2);

end.

Bình luận (0)
Toản Nguyễn
Xem chi tiết
Nguyễn Lê Phước Thịnh
24 tháng 1 2021 lúc 21:02

uses crt;

var a:array[1..20]of integer;

i,n,t,dem:integer;

begin

clrscr;

for i:=1 to 20 do 

  begin

repeat

write('A[',i,']='); readln(a[i]);

until a[i]>0;

end;

t:=0;

for i:=1 to 20 do 

  t:=t+a[i];

writeln('Tong cac so trong mang la: ',t);

dem:=0;

for i:=1 to 20 do 

  if a[i] mod 2=0 then inc(dem);

writeln('Trong mang co ',dem,' so chan');

readln;

end.

Bình luận (0)
Anh Thư Nguyễn
Xem chi tiết
Thu Hiền
Xem chi tiết