CF1202D.Print a 1337-string...

普及+/提高

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn.

You have to find a sequence ss consisting of digits 1,3,7{1, 3, 7} such that it has exactly nn subsequences equal to 13371337.

For example, sequence 337133377337133377 has 66 subsequences equal to 13371337:

  1. 3371‾33‾3‾77‾337\underline{1}3\underline{3}\underline{3}7\underline{7} (you can remove the second and fifth characters);
  2. 3371‾3‾33‾77‾337\underline{1}\underline{3}3\underline{3}7\underline{7} (you can remove the third and fifth characters);
  3. 3371‾3‾3‾377‾337\underline{1}\underline{3}\underline{3}37\underline{7} (you can remove the fourth and fifth characters);
  4. 3371‾33‾3‾7‾7337\underline{1}3\underline{3}\underline{3}\underline{7}7 (you can remove the second and sixth characters);
  5. 3371‾3‾33‾7‾7337\underline{1}\underline{3}3\underline{3}\underline{7}7 (you can remove the third and sixth characters);
  6. 3371‾3‾3‾37‾7337\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 ss must not exceed 10510^5.

You have to answer tt independent queries.

子序列是指通过删除原序列中的一些元素(不改变剩余元素的顺序)而得到的序列。

给定一个整数 nn。

你需要构造一个仅由数字 {1,3,7}\{1, 3, 7\} 组成的序列 ss,使得其恰好包含 nn 个等于 13371337 的子序列。

例如,序列 337133377337133377 包含 66 个等于 13371337 的子序列:

  1. 3371‾33‾3‾77‾337\underline{1}3\underline{3}\underline{3}7\underline{7}(可删除第 2 和第 5 个字符);
  2. 3371‾3‾33‾77‾337\underline{1}\underline{3}3\underline{3}7\underline{7}(可删除第 3 和第 5 个字符);
  3. 3371‾3‾3‾377‾337\underline{1}\underline{3}\underline{3}37\underline{7}(可删除第 4 和第 5 个字符);
  4. 3371‾33‾3‾7‾7337\underline{1}3\underline{3}\underline{3}\underline{7}7(可删除第 2 和第 6 个字符);
  5. 3371‾3‾33‾7‾7337\underline{1}\underline{3}3\underline{3}\underline{7}7(可删除第 3 和第 6 个字符);
  6. 3371‾3‾3‾37‾7337\underline{1}\underline{3}\underline{3}3\underline{7}7(可删除第 4 和第 6 个字符)。

注意:序列 ss 的长度不得超过 10510^5。

你需要回答 tt 个相互独立的查询。

输入格式

The first line contains one integer tt (1≤t≤101 \le t \le 10) — the number of queries.

Next tt lines contains a description of queries: the ii-th line contains one integer nin_i (1≤ni≤1091 \le n_i \le 10^9).

第一行包含一个整数 tt(1≤t≤101 \le t \le 10)—— 查询的次数。

接下来的 tt 行描述了各次查询:第 ii 行包含一个整数 nin_i(1≤ni≤1091 \le n_i \le 10^9)。

输出格式

For the ii-th query print one string sis_i (1≤∣si∣≤1051 \le |s_i| \le 10^5) consisting of digits 1,3,7{1, 3, 7}. String sis_i must have exactly nin_i subsequences 13371337. If there are multiple such strings, print any of them.

对于第 ii 个查询,输出一个仅由数字 1,3,7{1, 3, 7} 组成的字符串 sis_i(1≤∣si∣≤1051 \le |s_i| \le 10^5),使得 sis_i 恰好包含 nin_i 个子序列 1337。若存在多个满足条件的字符串,输出任意一个即可。

输入输出样例

  • 输入#1

    2
    6
    1

    输出#1

    113337
    1337

输入解题思路,AI测评打分。不知道怎么写?

首页