fork download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. int main()
  5. {
  6. int square = 1;
  7. int square_count = 1;
  8. int rice_count = 1000;
  9. while(square <= rice_count)
  10. {
  11. std::cout << square_count << " squares have been used. " << square << " rices count." << std::endl;
  12. square_count++;
  13. if (square == 1)
  14. {
  15. square++;
  16. }
  17. else
  18. {
  19. square = square * square;
  20. }
  21. }
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
1 squares have been used. 1 rices count.
2 squares have been used. 2 rices count.
3 squares have been used. 4 rices count.
4 squares have been used. 16 rices count.
5 squares have been used. 256 rices count.