fix lq148jz bug

This commit is contained in:
Zengtudor 2024-08-24 17:20:59 +08:00
parent ba9ec63d10
commit f0ba77c0bb
1 changed files with 12 additions and 11 deletions

View File

@ -1,14 +1,14 @@
#include<bits/stdc++.h>
using namespace std;
bool is_pf(int n){
int a = sqrt(n);
if(a*a==n){
return true;
}else{
return false;
}
}
// bool is_pf(int n){
// int a = sqrt(n);
// if(a*a==n){
// return true;
// }else{
// return false;
// }
// }
bool is_huiwen(int n){
stringstream ss;
@ -29,9 +29,10 @@ int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
if(is_pf(i)&&is_huiwen(i)){
cout<<i<<" ";
const int sqrt_n = sqrt(n);
for(int i=1;i<=sqrt_n;i++){
if(is_huiwen(i*i)){
cout<<i*i<<" ";
}
}
cout<<endl;