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 27 28
|
#include <cstdlib>
#include <iostream>
constexpr std::uint64_t repeat_one(int n)
{
constexpr std::uint64_t lut[] =
{
UINT64_C(0),
UINT64_C(1), UINT64_C(11),
UINT64_C(111), UINT64_C(1111),
UINT64_C(11111), UINT64_C(111111),
UINT64_C(1111111), UINT64_C(11111111),
UINT64_C(111111111), UINT64_C(1111111111),
UINT64_C(11111111111), UINT64_C(111111111111),
UINT64_C(1111111111111), UINT64_C(11111111111111),
UINT64_C(111111111111111), UINT64_C(1111111111111111),
UINT64_C(11111111111111111), UINT64_C(111111111111111111),
UINT64_C(1111111111111111111), UINT64_C(11111111111111111111)
};
return lut[n];
}
int main()
{
for (int i = 0; i <= 20; ++i)
std::cout << repeat_one(i) << '\n';
}
|