

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <iostream>
#include <math.h>
#define ll long long
using namespace std;
bool prime(ll n) {
for (ll i=2; i<=sqrt(n); i++) if (n%i==0) return false;
return n>=2;
}
int main() {
ll n;
cin >> n;
while (prime(n)) {
n/=10;
}
if (n==0) cout << "YES";
else cout << "NO";
}
Hãy giúp mọi người biết câu trả lời này thế nào?
#include <bits/stdc++.h>
#define ll long long
#define fr ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const long long N=1e2+5,N1=1e3+5,N2=1e4+5,N3=1e5+5,N4=1e6+5,N5=1e7+5,mod=1e9+7,maxv=1e9;
bool checkprime(ll n){
if(n<=1){
return false;
}
if(n<=3){
return true;
}
if(n%2==0||n%3==0){
return false;
}
for(ll i=5;i*i<=n;i+=6){
if(n%i==0||n%(i+2)==0){
return false;
}
}
return true;
}
bool check(ll n){
while(checkprime(n)){
n/=10;
}
return checkprime(n);
}
ll n;
int main(){
fr;
//freopen(".inp","r",stdin);
//freopen(".out","w",stdout);
cin>>n;
if(check(n)){
cout<<"YES";
}
else{
cout<<"NO";
}
}
//code was written by longdegea11
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin