K
Khách

Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.

29 tháng 12 2020

phần a

29 tháng 12 2020

phần b

#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;

}

14 tháng 1

#include <bits/stdc++.h> #define N int(1e7) #define sp ios_base::sync_with_stdio(0),cin.tie(0),cin.tie(0),cout.tie(0); using namespace std; long long l,r,d=0,b[N]; bool a[N]; void sang() { a[1]=true; for(int i=2; i*i<=N; i++) if(a[i]==false) for(int j=i*i; j<=N; j+=i) a[j]=true; for(int i=1; i<=N; i++) { if(a[i]==false) d+=i; b[i]=d; } } int main() { sp sang(); int t; while(t--) { cin>>l>>r; cout<<b[r]-b[l-1]<<'\n'; } }

27 tháng 10 2021

#include <bits/stdc++.h>

using namespace std;

long long n,i,x,k;

int main()

{

cin>>n>>k;

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

{

cout<<x;

if (x==k) cout<<i<<" ";

}

return 0;

}

18 tháng 12 2021

#include <bits/stdc++.h>

using namespace std;

long long x,n,i,t;

int main()

{

cin>>n;

t=0;

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

{

cin>>x;

t=t+x;

}

cout<<t;

return 0;

}

1 tháng 3 2021

Thiếu đề!!

1 tháng 3 2021

tham khảo

#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;

}

#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;

}