10 条题解
-
6赵星浩 (2022ts153) LV 7 @ 2022-12-21 13:29:25
水题。 AC代码:
#include<iostream> using namespace std; int n; bool check(int x){ int y=x*x; while(x!=0){ if(x%10!=y%10)return false; x/=10; y/=10; } return true; } int main(){ cin>>n; for(int j=2;j<=n;j++){ if(check(j))cout<<j<<" "; } return 0; }
点个赞吧!
-
22022-12-9 17:57:58@
#include<iostream> #include<iomanip> #include<math.h> using namespace std; int main(){ int n; cin>>n; for(int i=2;i<=n;i++){ if(i==i*i%10||i==i*i%100||i==i*i%1000){ cout<<i<<" "; } } }
-
02023-9-8 18:39:25@
#include <bits/stdc++.h> using namespace std; const int N=32000+10; const int INF=0x3f3f3f3f; int r; bool c(int x) { long long y=x*x; long long sum=1; while(x>=10*sum) { sum*=10; } if( (y-x) % (10*sum) ==0) { return 1; } return 0; } int main() { cin>>r; for(int i=2;i<=r;i++) { if(c(i)) { cout<<i<<" "; } } return 0; }
水
-
-12022-10-25 18:44:42@
#include <iostream> #include <stack> #include <cmath> #include <vector> #include <string.h> #include <queue> #include <stdio.h> #include <iomanip> #include <cstdio> #include <algorithm> #define int long long using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int wei(int x) { int num = 1; while(x >= 10) { num ++; x /= 10; } return num; } bool jian(int x, int y) { int sum = x - y; int len = wei(y); if(len == 1) { if(sum % 10 == 0) { return 1; } } if(len == 2) { if(sum % 100 == 0) { return 1; } } if(len == 3) { if(sum % 1000 == 0) { return 1; } } else { if(sum % 10000 == 0) { return 1; } } return 0; } int fang(int x) { return x * x; } signed main() { int n; cin >> n; for(int i = 2; i <= n; i++) { if(jian(fang(i), i) == 1) { cout << i << " "; } } cout << endl; return 0; }
我太菜了
-
-12022-7-9 9:57:44@
//***************************
//dev c++[[990.cpp]]*******
//dev c++[top fanil]]******
//dev c++*www.temege.com
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <vector>
#include <iomanip>
using namespace std;
int main()
{
int n; cin>>n; for(int i=2;i<=n;i++) { int k=i*i; if(i<10) { if(k%10==i) { cout<<i<<" "; } } else if(i<100) { if(k%100==i) { cout<<i<<" "; } } else { if(k%1000==i) { cout<<i<<" "; } } } return 0;
}
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
////////////////////////////
-
-12022-2-20 20:38:43@
#include <iostream> #include <math.h> using namespace std; int main() {#include <iostream> #include <math.h> using namespace std; int main() { int n; cin >> n; for (int i = 5; i <= n; i++) { int sum = ii; int flag = 0; int ans = 0; for (int j = 1; sum!= 0;j = j10) { ans = ans +(sum%10)*j; sum/=10; if (ans == i) { flag = 1; }
} if (flag == 1) { cout<< i << " "; } }
}
-
-42022-1-11 10:44:43@
#include <iostream> #include <math.h> using namespace std; int main() { int n; cin >> n; for (int i = 5; i <= n; i++) { int sum = i*i; int flag = 0; int ans = 0; for (int j = 1; sum!= 0;j = j*10) { ans = ans +(sum%10)*j; sum/=10; if (ans == i) { flag = 1; } } if (flag == 1) { cout<< i << " "; } } }
-
-62022-1-11 10:51:20@
#include <stdio.h> #include <iostream> #include <math.h> using namespace std; int main() { int n; cin>>n; for(int i=5;i<=n;i++) { int sum=i*i; int flag=0; int ans=0; for(int j=1;sum!=0;j=j*10) { ans=ans+(sum%10)*j; sum/=10; if(ans==i) { flag=1; } } if(flag==1) { cout<<i<<" "; } } }
-
-62022-1-11 10:45:04@
#include <iostream> #include <math.h> using namespace std; int main() { int n; cin >> n; for (int i = 5; i <= n; i++) { int sum = i*i; int flag = 0; int ans = 0; for (int j = 1; sum!= 0;j = j*10) { ans = ans +(sum%10)*j; sum/=10; if (ans == i) { flag = 1; } } if (flag == 1) { cout<< i << " "; } } }
-
-62022-1-11 10:45:03@
#include <iostream> #include <math.h> using namespace std; int main() { int n; cin >> n; for (int i = 5; i <= n; i++) { int sum = i*i; int flag = 0; int ans = 0; for (int j = 1; sum!= 0;j = j*10) { ans = ans +(sum%10)*j; sum/=10; if (ans == i) { flag = 1; } } if (flag == 1) { cout<< i << " "; } } }
- 1
信息
- ID
- 941
- 时间
- 1000ms
- 内存
- 32MiB
- 难度
- 4
- 标签
- 递交数
- 367
- 已通过
- 180
- 上传者