Description
![](https://kickstart.best/wp-content/uploads/2020/12/image-6-1024x913.png)
Submission
class Solution { public: int concatenatedBinary(int n) { long long res = 1; long long M = 1e9 + 7; for(int i = 2; i <= n; ++i) { int pos = log(i) / log(2)+1; res = ((res << pos) % M + i) % M; } return res; } }; // n = 1: 1 // n = 2: 1 10 // n = 3: 110 11 // res[n] = ()res[n-1]*2^l+n)M
![](https://kickstart.best/wp-content/uploads/2020/12/image-7-1024x629.png)