A12835 | Print a 1337-string...
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
You are given an integer $n$ .
You have to find a sequence $s$ consisting of digits $\{1, 3, 7\}$ such that it has exactly $n$ subsequences equal to $1337$ .
For example, sequence $337133377$ has $6$ subsequences equal to $1337$ :
1. $337\underline{1}3\underline{3}\underline{3}7\underline{7}$ (you can remove the second and fifth characters);
2. $337\underline{1}\underline{3}3\underline{3}7\underline{7}$ (you can remove the third and fifth characters);
3. $337\underline{1}\underline{3}\underline{3}37\underline{7}$ (you can remove the fourth and fifth characters);
4. $337\underline{1}3\underline{3}\underline{3}\underline{7}7$ (you can remove the second and sixth characters);
5. $337\underline{1}\underline{3}3\underline{3}\underline{7}7$ (you can remove the third and sixth characters);
6. $337\underline{1}\underline{3}\underline{3}3\underline{7}7$ (you can remove the fourth and sixth characters).
Note that the length of the sequence $s$ must not exceed $10^5$ .
You have to answer $t$ independent queries.
You are given an integer $n$ .
You have to find a sequence $s$ consisting of digits $\{1, 3, 7\}$ such that it has exactly $n$ subsequences equal to $1337$ .
For example, sequence $337133377$ has $6$ subsequences equal to $1337$ :
1. $337\underline{1}3\underline{3}\underline{3}7\underline{7}$ (you can remove the second and fifth characters);
2. $337\underline{1}\underline{3}3\underline{3}7\underline{7}$ (you can remove the third and fifth characters);
3. $337\underline{1}\underline{3}\underline{3}37\underline{7}$ (you can remove the fourth and fifth characters);
4. $337\underline{1}3\underline{3}\underline{3}\underline{7}7$ (you can remove the second and sixth characters);
5. $337\underline{1}\underline{3}3\underline{3}\underline{7}7$ (you can remove the third and sixth characters);
6. $337\underline{1}\underline{3}\underline{3}3\underline{7}7$ (you can remove the fourth and sixth characters).
Note that the length of the sequence $s$ must not exceed $10^5$ .
You have to answer $t$ independent queries.
输入格式
The first line contains one integer $t$ ( $1 \le t \le 10$ ) — the number of queries.
Next $t$ lines contains a description of queries: the $i$ -th line contains one integer $n_i$ ( $1 \le n_i \le 10^9$ ).
Next $t$ lines contains a description of queries: the $i$ -th line contains one integer $n_i$ ( $1 \le n_i \le 10^9$ ).
输出格式
For the $i$ -th query print one string $s_i$ ( $1 \le |s_i| \le 10^5$ ) consisting of digits $\{1, 3, 7\}$ . String $s_i$ must have exactly $n_i$ subsequences $1337$ . If there are multiple such strings, print any of them.
输入输出样例
输入 #1
2 6 1
输出 #1
113337 1337
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted