2 条题解
-
1
#include <bits/stdc++.h> using namespace std; int ap(int n) { if (n % 11 == 0) return true; return false; } int bp(int n) { int a[11]; for (int i = 1; i <= 9; i++) a[i] = 0; while (n > 0) { if (a[n % 10] == 0) a[n % 10]++; else return false; n /= 10; } return true; } int cp(int n) { int a = n / 1000 % 10; int b = n / 100 % 10; int c = n / 10 % 10; if (b + c == a) return true; return false; } int dp(int n) { int b = n / 100 % 10; int c = n / 10 % 10; int a = b * 10 + c; for (int i = 1; i <= 9; i++) { if (a == i * i) return true; } return false; } int main() { int r, l, ans = 0; bool flag = false; cin >> l >> r; for (int i = l; i <= r; i++) { if (ap(i) && bp(i) && cp(i) && dp(i)) { cout << i << " "; flag = true; ans++; } } if (!flag) cout << "No Answer." << endl; else cout << endl << ans << endl; return 0; } -
-1
有我在,绝对给你满分的题解
#include<iostream> #include<math.h> #include<string.h> using namespace std; int n,m,a[10],cnt; bool check1(int x){//判断每一位是否重复 memset(a,0,sizeof(a)); while(x){ if(a[x%10]==0)a[x%10]++; else return false; x/=10; } return true; } bool check2(int i){ int a=i/1000,b=i/100%10,c=i/10%10,d=i%10; if(check1(i)&&i%11==0&&b+c==a){ int k=b*10+c; for(int i=1;i<=10;i++){//判断平方数 if(k==i*i)return true; } return false; } } int main(){ cin>>n>>m; for(int i=n;i<=m;i++){ if(check2(i)){ cout<<i<<" "; cnt++; } } if(cnt)cout<<endl<<cnt; else cout<<"No Answer."; return 0; }
- 1
信息
- ID
- 949
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 8
- 标签
- 递交数
- 81
- 已通过
- 15
- 上传者