题意
- 输出一个含有n个子序列为“1337”的串
思路
- 找这种形式的串133(777...)(333...)7
- 中间7的个数_7, 中间3的个数_3【别忘了前边的3. 子序列“1337”的个数为_7+C(_3, 2)
- 只需要尽可能找到大的C(_3, 2),那么剩余的就是7
【误解】不能用乘法来做!可能有些人(比如我)就会想找到尽可能大的一个组合数是n的一个因子,但是如果n是大质数呢?会爆T. 实际上不仅仅T,答案也是不合法的,超出了1e5【不信可以试试嘛,我试了反正,2e5+】. 爆T只是因为你还没输出完就已经超时了(第二组十个大数)
#include <bits/stdc++.h>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
inline int read()
{
int x = 0, f = 1; char c = getchar();
while(c < '0' || c > '9') { if(c == '-') f = -f; c = getchar(); }
while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
return x * f;
}
const int maxN = 100005;
int C[maxN], cnt;
void pre()
{
for(int i = 2; ; ++ i )
{
++ cnt;
C[i] = i * (i - 1) / 2;
if(C[i] > 1000000000)
break;
}
}
int n;
int main()
{
pre();
int TAT; TAT = read();
while(TAT -- )
{
n = read();
//中间的3的个数
int _3 = lower_bound(C + 2, C + cnt + 2, n) - C - 1;
int _7;
if(_3 == 1)
_3 = _7 = 0;
else
_7 = n - C[_3], _3 -= 2;
printf("133");
while(_7 -- )
putchar('7');
while(_3 -- )
putchar('3');
putchar('7');
putchar('\n');
}
return 0;
}