fork download
  1. #include <math.h>
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6. for (int i = 1; i <= 1000; i++)
  7. {
  8. if (fabs(pow(i, 0.5) - (int)(pow(i, 0.5) + 0.000001)) < 0.001 ||
  9. fabs(pow(i, 1/3.0) - (int)(pow(i, 1/3.0) + 0.000001)) < 0.001)
  10. cout << i << endl;
  11. }
  12. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
1
4
8
9
16
25
27
36
49
64
81
100
121
125
144
169
196
216
225
256
289
324
343
361
400
441
484
512
529
576
625
676
729
784
841
900
961
1000