http://codeforces.com/contest/489/problem/C
Tarsus is from the highest level, to big big; that is, from the lowest decimal place, small as it is small, then the next highest bit processing is zero.
No results nothing more than a small sum, min are all 0, a sum too, there are all the remaining 9
1 public class Main {
2 public static void main(String[] args) {
3 Scanner io = new Scanner(System.in);
4 int len = io.nextInt(), sum = io.nextInt();
5 int[] max = new int[len + 1];
6 int[] min = new int[len + 1];
7
8 int sum1 = sum, sum2 = sum;
9 for (int i = 1; i <= len; sum1 -= max[i++]) max[i] = Math.min(9, SUM1);
10 for ( int I = len; I> =. 1; SUM2 - = min [i--]) min [I] = Math.min (. 9 , SUM2);
. 11
12 is // min is the least most significant bit . 1
13 is IF (min [. 1] == 0) for ( int I = 2; I <= len; I ++ )
14 IF (min [I]> 0 ) {
15 min [I] - ;
16 min [. 1] ++ ;
. 17 BREAK ;
18 is }
. 19
20 is // SUM too small: min are all set to 0
21 is int nomin =. 1 ;
22 is for (int i = 1; i <= len; i++) if (min[i] != 0) nomin = 0;
23
24 //sum太大:sum1、sum2没减完
25 if ((nomin == 1 && len != 1) || sum1 != 0 || sum2 != 0) System.out.println("-1 -1");
26 else {
27 for (int i = 1; i <= len; i++) System.out.print(min[i]);
28 System.out.print(" ");
29 for (int i = 1; i <= len; i++) System.out.print(max[i]);
30 }
31 }
32 }