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.
uses crt;
var i,n,m,k,d:integer;
{---------------chuong-trinh-con-tim-ucln--------------------}
function ucln(x,y:integer):integer;
var t:integer;
begin
while y<>0 do
begin
t:=x mod y;
x:=y;
y:=t;
end;
ucln:=x;
end;
{------------chuong-trinh-con-kiem-tra-so-nguyen-to-------------------}
function nt(b:longint):boolean;
var j:longint;
begin
nt:=true;
if (b=2) or (b=3) then exit;
nt:=false;
if (b=1) or (b mod 2=0) or (b mod 3=0) then exit;
j:=5;
while j<=trunc(sqrt(b)) do
begin
if (b mod j=0) or (b mod (j+2)=0) then exit;
j:=j+6;
end;
nt:=true;
end;
{---------------chuong-trinh-chinh---------------------}
begin
clrscr;
write('Nhap N: '); readln(N);
write('Nhap M: '); readln(M);
d:=0;
k:=ucln(N,M);
for i:=1 to k do
if nt(i) then d:=d+1;
if d>0 then writeln('2 so nay tuong duong voi nhau')
else writeln('2 so nay khong tuong duong voi nhau');
readln;
end.
uses crt; var a,b:array[1..100000]of integer; i,n,kt,j,dem,x,y,kt1:integer; st,st1:string; begin clrscr; write('Nhap n='); readln(n); for i:=1 to n do begin write('A[',i,']='); readln(a[i]); end; dem:=0; for i:=1 to n do if a[i]>1 then begin kt:=0; for j:=2 to a[i]-1 do if a[i] mod j=0 then begin kt:=1; break; end; if kt=0 then begin inc(dem); b[dem]:=a[i]; end; end; for i:=1 to dem do begin str(a[i],st); st1:=''; for j:=length(st) downto 1 do st1:=st1+st[j]; val(st1,x,y); kt1:=0; for j:=2 to x-1 do if x mod j=0 then begin kt1:=1; break; end; if kt1=0 then write(a[i]:4); end; readln; end.
uses crt; var a,b:array[1..100000]of integer; i,n,kt,j,dem,x,y,kt1:integer; st,st1:string; begin clrscr; write('Nhap n='); readln(n); for i:=1 to n do begin write('A[',i,']='); readln(a[i]); end; dem:=0; for i:=1 to n do if a[i]>1 then begin kt:=0; for j:=2 to a[i]-1 do if a[i] mod j=0 then begin kt:=1; break; end; if kt=0 then begin inc(dem); b[dem]:=a[i]; end; end; for i:=1 to dem do begin str(a[i],st); st1:=''; for j:=length(st) downto 1 do st1:=st1+st[j]; val(st1,x,y); kt1:=0; for j:=2 to x-1 do if x mod j=0 then begin kt1:=1; break; end; if kt1=0 then write(a[i]:4); end; readln; end.
uses crt;
var i,n,s: integer;
a:array[1..100] of integer;
begin
writeln('Nhap n: '); read(n);
for i:=1 to n do
begin
write('a[',i,'] = '); readln(a[i]);
end;
writeln('Cac so le: ')
s:=0;
for i:=1 to n do
if a[i] mod 2 <> 0 then
begin
s:=s+a[i];
write(a[i],' ');
end;
writeln('- Tong so le: ',s);
for i:=1 to trunc(sqrt(s)) do if s mod i = 0 then d:=d+1;
if d > 1 then writeln('Tong do khong la so nguyen to') else writeln('Tong do la so nguyen to');
readln
end.
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i;
bool kt;
int main()
{
getline(cin,st);
kt=true;
d=st.length();
for (i=0; i<=d-1; i++)
if (st[i]!=st[d-i-1]) kt=false;
if (kt==true) cout<<"YES";
else cout<<"NO";
return 0;
}
#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;
}
#include <bits/stdc++.h>
using namespace std;
string st;
int d,i;
bool kt;
int main()
{
cin>>st;
d=st.length();
kt=true;
for (i=0; i<=d-1; i++)
if ((st[i]!='6') and (st[i]!='8')) kt=false;
if (kt==true) cout<<"YES";
else cout<<"NO";
return 0;
}
#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;
}