#include <iostream>
#include <vector>
std::vector<int> GenerateArray(std::size_t N){
std::vector<int> vec;
vec.push_back(0);
vec.push_back(1);
//vec.push_back(2);
for (std::size_t i = 1; i < N; i++)
{
vec.push_back(1 + vec[i + 1 - vec[vec[i]]]);
if (vec.size() > N) return vec;
}
return vec;
}
int main(){
auto R = GenerateArray(1000);
std::cout <<"N=10:"<< R[10] << std::endl;
std::cout <<"N=100:"<< R[100] << std::endl;
std::cout <<"N=1000:"<< R[1000] << std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RkOjp2ZWN0b3I8aW50PiBHZW5lcmF0ZUFycmF5KHN0ZDo6c2l6ZV90IE4pewoJc3RkOjp2ZWN0b3I8aW50PiB2ZWM7CgoJdmVjLnB1c2hfYmFjaygwKTsKCXZlYy5wdXNoX2JhY2soMSk7CgkvL3ZlYy5wdXNoX2JhY2soMik7CgoJZm9yIChzdGQ6OnNpemVfdCBpID0gMTsgaSA8IE47IGkrKykKCXsKCQl2ZWMucHVzaF9iYWNrKDEgKyB2ZWNbaSArIDEgLSB2ZWNbdmVjW2ldXV0pOwoJCWlmICh2ZWMuc2l6ZSgpID4gTikgcmV0dXJuIHZlYzsKCX0KCXJldHVybiB2ZWM7Cn0KCmludCBtYWluKCl7CglhdXRvIFIgPSBHZW5lcmF0ZUFycmF5KDEwMDApOwoKCXN0ZDo6Y291dCA8PCJOPTEwOiI8PCBSWzEwXSA8PCBzdGQ6OmVuZGw7CglzdGQ6OmNvdXQgPDwiTj0xMDA6Ijw8IFJbMTAwXSA8PCBzdGQ6OmVuZGw7CglzdGQ6OmNvdXQgPDwiTj0xMDAwOiI8PCBSWzEwMDBdIDw8IHN0ZDo6ZW5kbDsKCglyZXR1cm4gMDsKfQ==