fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. bool pass( int n )
  5. {
  6. int p = static_cast<int>(std::log10(n))+1;
  7. return (n*n) % static_cast<int>(std::pow(10,p)) == n;
  8. }
  9.  
  10. int main() {
  11.  
  12. for( int i=1; i<10000; ++i )
  13. {
  14. if( pass(i) ) std::cout << i << std::endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
1
5
6
25
76
376
625
9376