aabb问题
1.简单的计算
#include<stdio.h> #include<math.h> int main(){ int a, b, n; double m; for(a = 1; a <= 9; a++){ for(b = 0; b <= 9; b++){ n = a * 1100 + b * 11; m = sqrt(n); if(floor(m + 0.5) == m){ printf("%d\n",n); } } } return 0; }
2.枚举
#include<stdio.h> #include<math.h> int main(){ int m, a, b; for(int i = 32; i <= 9999; i++){ m = i * i; a = m / 100; b = m % 100; if(a / 10 == a % 10 && b / 10 == b % 10){ printf("%d\n",m); } } return 0; }