F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Matchsticks

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 973    Accepted Submission(s): 384


Problem Description
Matchsticks are ideal tools to represent numbers. A common way to represent the ten decimal digits with matchsticks is the following:



This is identical to how numbers are displayed on an ordinary alarm clock. With a given number of matchsticks you can generate a wide range of numbers. We are wondering what the smallest and largest numbers are that can be created by using all your matchsticks.
 

Input
On the first line one positive number: the number of testcases, at most 100. After that per testcase:

* One line with an integer n (2 ¡Ü n ¡Ü 100): the number of matchsticks you have.
 

Output
Per testcase:

* One line with the smallest and largest numbers you can create, separated by a single space. Both numbers should be positive and contain no leading zeroes.
 

Sample Input
4 3 6 7 15
 

Sample Output
7 7 6 111 8 711 108 7111111
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-27 00:30:21, Gzip enabled