File size: 563 Bytes
c4b0eef
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> v;
    int last = 5;
    v.push_back(0);
    v.push_back(1);
    v.push_back(3);
    v.push_back(5);
    for (int i = 4; true; i++) {
        int res = lower_bound(v.begin(), v.end(), i) - v.begin();
        last += res;
        v.push_back(last);
        if (last > 2000000000) break;
    }
    int n;
    while (cin >> n && n != 0) {
        int res = lower_bound(v.begin(), v.end(), n) - v.begin();
        printf("%d\n", res);
    }
    return 0;
}