fork(3) download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <iomanip>
  5. using namespace std;
  6.  
  7. int main() {
  8. int i = 10;
  9. int k = 1;
  10. for(;;)
  11. {
  12. float prev = 0.0f;
  13. for(int j = 1; j <= i; ++j)
  14. {
  15. stringstream ss;
  16. ss << "0.";
  17. ss << setfill('0') << setw(k) << j;
  18. float next;
  19. ss >> next;
  20. if(prev == next) return 0;
  21. prev = next;
  22. }
  23. cout << "Works for " << k << " places" << endl;
  24. i *= 10;
  25. k++;
  26. }
  27. return 0;
  28. }
Time limit exceeded #stdin #stdout 5s 3432KB
stdin
Standard input is empty
stdout
Works for 1 places
Works for 2 places
Works for 3 places
Works for 4 places
Works for 5 places
Works for 6 places