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.
const fi='tong.inp';
fo='tong.out';
var f1,f2:text;
a:array[1..100]of integer;
n,i,t: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,t);
close(f1);
close(f2);
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i;
bool kt;
int main()
{
cin>>n;
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if ((kt==true) and (n>1)) cout<<"YES";
else cout<<"NO";
return 0;
}
const fi='input.txt';
fo='output.txt';
var f1,f2:text;
n:integer;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,n);
if n<0 then writeln(f2,n,' la so am')
else if n=0 then writeln(f2,n,' khong la so am cung khong la so duong')
else writeln(f2,n,' la so duong');
close(f1);
close(f2);
end.
#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;
}
#include <bits/stdc++.h>
using namespace std;
long long n,i,j,dem;
bool kt;
int main()
{
freopen("dnto.inp","r",stdin);
freopen("dnto.out","w",stdout);
cin>>n;
for (i=2; i<=n; i++)
{
kt=true;
for (j=2; j*j<=i; j++)
if (i%j==0) kt=false;
if (kt==true) dem++;
}
cout<<dem;
return 0;
}
Bài 1:
const fi='b5.inp.txt';
fo='b5.out.txt';
var f1,f2:text;
a:array[1..255]of integer;
i,n,kt,j,dem: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]);
dem:=0;
max:=1;
for i:=1 to n do
if a[i]>1 then
begin
kt:=0;
for j:=2 to trunc(sqrt(a[i])) do
if a[i] mod j=0 then kt:=1;
if kt=0 then
begin
inc(dem);
if max<a[i] then max:=a[i];
end;
end;
writeln(f2,dem);
if dem=0 then writeln(f2,'Khong co so nguyen to trong day')
else writeln(f2,max);
close(f1);
close(f2);
end.
#include <bits/stdc++.h>
using namespace std;
long long n,i;
bool kt;
int main()
{
freopen("checknto.inp","r",stdin);
freopen("checknto.out","w",stdout);
cin>>n;
kt=true;
for (i=2; i*i<=n; i++)
if (n%i==0) kt=false;
if (kt==true && n>1) cout<<"YES";
else cout<<"NO";
return 0;
}