同构数.c 291 B

12345678910111213141516171819202122232425
  1. #include <stdio.h>
  2. int tonggou(int num) {
  3. int square = num * num;
  4. int i = 10;
  5. while(i <= 1000) {
  6. if(num == square % i) return 1;
  7. i *= 10;
  8. }
  9. return 0;
  10. }
  11. int main() {
  12. int a,b;
  13. scanf("%d %d",&a,&b);
  14. while(a <= b) {
  15. if(tonggou(a)) printf("%d\n",a);
  16. a++;
  17. }
  18. return 0;
  19. }