#include <iostream>
#include <vector>
std::vector<std::size_t> GanerateArray(std::size_t N){
std::vector<std::size_t> vec;
std::size_t undefined;//不定値
vec.push_back(undefined);//不備??昇順なので、0か1の可能性。
vec.push_back(1);//絶対条件
vec.push_back(2);//seed??
for (std::size_t i = 2; i < N; i++)
{
for (std::size_t j = 0; j < vec[i]; j++)
{
vec.push_back(i);
if (vec.size() > N) return vec;
}
}
return vec;
}
int main(){
auto A = GanerateArray(1000);
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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgoKc3RkOjp2ZWN0b3I8c3RkOjpzaXplX3Q+IEdhbmVyYXRlQXJyYXkoc3RkOjpzaXplX3QgTil7CgoJc3RkOjp2ZWN0b3I8c3RkOjpzaXplX3Q+IHZlYzsKCXN0ZDo6c2l6ZV90IHVuZGVmaW5lZDsvL+S4jeWumuWApAoKCXZlYy5wdXNoX2JhY2sodW5kZWZpbmVkKTsvL+S4jeWCme+8n++8n+aYh+mghuOBquOBruOBp+OAgTDjgYsx44Gu5Y+v6IO95oCn44CCCgl2ZWMucHVzaF9iYWNrKDEpOy8v57W25a++5p2h5Lu2Cgl2ZWMucHVzaF9iYWNrKDIpOy8vc2VlZD8/CgoJZm9yIChzdGQ6OnNpemVfdCBpID0gMjsgaSA8IE47IGkrKykKCXsKCQlmb3IgKHN0ZDo6c2l6ZV90IGogPSAwOyBqIDwgdmVjW2ldOyBqKyspCgkJewoJCQl2ZWMucHVzaF9iYWNrKGkpOwoJCQlpZiAodmVjLnNpemUoKSA+IE4pIHJldHVybiB2ZWM7CgkJfQoJfQoKCXJldHVybiB2ZWM7Cn0KCmludCBtYWluKCl7CglhdXRvIEEgPSBHYW5lcmF0ZUFycmF5KDEwMDApOwoKCXN0ZDo6Y291dCA8PCAiTj0xMDoiIDw8IEFbMTBdIDw8IHN0ZDo6ZW5kbDsKCXN0ZDo6Y291dCA8PCAiTj0xMDA6IiA8PCBBWzEwMF0gPDwgc3RkOjplbmRsOwoJc3RkOjpjb3V0IDw8ICJOPTEwMDA6IiA8PCBBWzEwMDBdIDw8IHN0ZDo6ZW5kbDsKCglyZXR1cm4gMDsKfQ==