思路
字符串构造
s.length() <= 1e5, 如果”111…337” or “133777…”“, max_s.length() = 1e5 - 3 << 1e9
如果”133777…333…7” max_s.length() = (1e5 - 2) * (1e5 - 3) / 2 > 1e9
“1333…7” 可构造1337: i * (i - 1) / 2 <==> C(i, 2) 个
用C(i, 2) <= n模拟出i的值如果i < n 在前面补(n - i)个”7”
拓展
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
int t;
int main()
{
cin >> t;
while(t -- )
{
int n;
cin >> n;
int m = 1;
while(m * (m - 1) / 2 <= n) m ++ ;
m -- ;
cout << "133";
for(int i = 0; i < n - m * (m - 1) / 2; i ++ ) cout << "7";
for(int i = 0; i < m - 2; i ++ ) cout << "3";
cout << "7" << endl;
}
return 0;
}