fork download
  1. #include <iostream>
  2.  
  3. std::size_t A(std::size_t N){
  4.  
  5. std::size_t C = 0;
  6.  
  7. for (std::size_t i = 0; i < N; i++)
  8. {
  9. C += i;
  10. if (C >= N) return i;
  11. }
  12.  
  13. return C;
  14. }
  15.  
  16. int main(){
  17. std::cout << "N=10:" << A(10) << std::endl;
  18. std::cout << "N=100:" << A(100) << std::endl;
  19. std::cout << "N=1000:" << A(1000) << std::endl;
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
N=10:4
N=100:14
N=1000:45