Đăng nhập để hỏi chi tiết


Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
`\color{#FFFFFF}{C}\color{#F5F3FF}{r}\color{#DDD6FE}{y}\color{#C4B5FD}{4}\color{#A78BFA}{u}`
`@` C++:
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false); // tăng tốc độ nhập xuất
cin.tie(nullptr);
int n;
cin >> n;
vector<bool> snt(n + 1, true);
snt[0] = snt[1] = false;
for (int i = 2; i * i <= n; i++) {
if (snt[i]) {
for (int j = i * i; j <= n; j += i)
snt[j] = false;
}
}
int dem = 0;
for (int i = 2; i < n; i++) {
if (!snt[i]) continue;
string s = to_string(i);
string t = s;
bool ok = true;
for (int k = 0; k < s.size(); k++) {
int x = stoi(t);
if (x >= n || !snt[x]) {
ok = false;
break;
}
rotate(t.begin(), t.begin() + 1, t.end());
}
if (ok) dem++;
}
cout << dem;
}
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 str string
using namespace std;
int main(){
ll n,d=0;
cin>>n;
vector<ll> a(n,1);
a[0]=a[1]=0;
for(ll i=2;i*i<n;i++)
if(a[i])
for(ll j=i*i;j<n;j+=i)a[j]=0;
for(ll x=2;x<n;x++){
if(!a[x])
continue;
str s=to_string(x);
ll y=x,k=s.size(),ok=1;
for(ll i=1;i<k;i++){
y=y%10*pow(10,k-1)+y/10;
if(!a[y])ok=0;
}
d+=ok;
}
cout<<d;
}Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
5083
3134
3178
nào bù xg hết nhắn cx đc, kh nhất thiết ph v đâu 🐧🗿
883
6888
831
- vag
883
6888
831
- Bù đủ rồi nha sếp
5083
3134
3178
ok, tày quá 🐧
883
6888
831
- :)
883
6888
831
- trình :)
5083
3134
3178
r cái j nx v 🥀💔
883
6888
831
- de e bù