#include <iostream>
std::size_t A(std::size_t N){
std::size_t C = 0;
for (std::size_t i = 0; i < N; i++)
{
C += i;
if (C >= N) return i;
}
return C;
}
int main(){
std::cout << "N=10:" << A(10) << std::endl;
std::cout << "N=100:" << A(100) << std::endl;
std::cout << "N=1000:" << A(1000) << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RkOjpzaXplX3QgQShzdGQ6OnNpemVfdCBOKXsKCglzdGQ6OnNpemVfdCBDID0gMDsKCglmb3IgKHN0ZDo6c2l6ZV90IGkgPSAwOyBpIDwgTjsgaSsrKQoJewoJCUMgKz0gaTsKCQlpZiAoQyA+PSBOKSByZXR1cm4gaTsKCX0KCglyZXR1cm4gQzsKfQoKaW50IG1haW4oKXsKCXN0ZDo6Y291dCA8PCAiTj0xMDoiIDw8IEEoMTApIDw8IHN0ZDo6ZW5kbDsKCXN0ZDo6Y291dCA8PCAiTj0xMDA6IiA8PCBBKDEwMCkgPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8ICJOPTEwMDA6IiA8PCBBKDEwMDApIDw8IHN0ZDo6ZW5kbDsKCglyZXR1cm4gMDsKfQ==