Những câu hỏi liên quan
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)
Mộng Chúc
Xem chi tiết
Nguyễn Lê Phước Thịnh
14 tháng 3 2022 lúc 10:03

#include <bits/stdc++.h>

using namespace std;

long long a[1000],i,n,j;

bool kt;

int main()

{

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

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

cin>>n;

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

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

if (a[i]>1) 

{

kt=true;

for (j=2; j*j<=a[i]; j++)

if (a[i]%j==0) kt=false;

if (kt==true) cout<<a[i]<<" ";

}

return 0;

}

Bình luận (0)
thiên thanh
Xem chi tiết
Ngọc Diệp
Xem chi tiết
nguyễn an phát
12 tháng 5 2021 lúc 20:24

program du_lieu;

uses crt;

var i,n:integer;

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

tbc:real;

f:text;

begin

clrscr;

assign(f,'DULIEU.INP');reset(f);

readln(f,n);

for i:=1 to n do

begin

read(f,a[i]);

end;

close(f);

for i:=1 to n do

tbc:=tbc+a[i];

writeln(tbc/n);

readln;

end.

Bình luận (0)
APOK FF
Xem chi tiết
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)
Nguyễn Thùy Dương
Xem chi tiết
Nguyễn Lê Phước Thịnh
26 tháng 10 2021 lúc 23:20

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,t,dem;

int main()

{

cin>>n;

dem=0;

t=0;

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

{

cin>>x;

if (x%2!=0) 

{

dem++;

t=t+x;

}

}

double s=t*1.0/dem*1.0;

cout<<fixed<<setprecision(2)<<s;

return 0;

}

Bình luận (0)
Minh Lệ
27 tháng 10 2021 lúc 6:22

Thuật toán liệt kê:

Bước 1: Nhập n và dãy A1,A2,..,An

Bước 2: TB←0; i←1; d←0;

Bước 3: Nếu i>n thì in ra TB/d và kết thúc

Bước 4: Nếu Ai mod 2=1 thì TB←TB+Ai và d←d+1;

Bước 5: i←i+1, quay lại bước 3

Bình luận (0)
Lala
Xem chi tiết
Trương Huy Hoàng
13 tháng 12 2023 lúc 22:58

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
map<ll,ll> mp;
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    freopen("MAP1.INP","r",stdin);
    freopen("MAP1.OUT","w",stdout);
    ll n; cin >> n;
    ll a[n+5];
    for(ll i=1;i<=n;i++) cin >> a[i], mp[a[i]]++;
    for(pair<ll,ll> it:mp) cout << it.first << " " << it.second << "\n";
}

Chúc bạn học tốt!

Bình luận (0)
TRIẾT PHẠM
Xem chi tiết