Jinixin's password

Time Limit: 1 Sec Memory Limit: 128 MB

Description

God of Jinixin is a great god that his IQ is at the top of his team. In his computer,

there are many things that he is learning. Every day, he through learning to improve

his levels of knowledge. However, as an elder, God of Jinixin don't want to his learning

materials are read by persons who are "too young, too simple and sometimes naive"

for fear that they make a big news. So, God of Jinixin sets a password in his computer.

Certainly, his password also on the basis of the fundamental laws. The fundamental

laws are made by himself. The laws are that:

1. The password is made up by two n-bit numbers, they are separated by spaces,

and the sums of each digit of the two numbers are s.

2. They are the smallest number and the biggest number that satisfy condition 1.

3. When can't find the sum s of the n-bit numbers, the password is -1 -1.

4. God of Jinixin ensure that there is no leading zeros in the two numbers.

His password is just for fear that persons who are "too young,too simple and

sometimes naive" enter the computer. For you, the high IQ people, it's should not too

hard to decipher password.

Input

Input contains an integer T(1<=T<=100) in the first line, and then T lines follow.

Each line consists of a pair of integers n(0<n<=100) and s(0<=s<=900), separated by a

space.

Output

For each test case, you should output the password of God of Jinixin.

Sample Input

1

2 15

Sample Output

69 96

HINT

For a test case, the sum of two figures is 15,and the smallest number is 69 and

the biggest number is 96.

18

 

#include<stdio.h>
#include<string.h>
int main()
{
    char a[1001],b[1001];
    int t,s,n,m,i,j;
    while(scanf("%d",&t)!=EOF)
    {
        while(t--)
        {
             scanf("%d%d",&n,&s);
            if(s>n*9||(n>1&&s==0))
            {printf("-1 -1\n");}
            else{
            memset(a,'0',sizeof(a));
        memset(b,'0',sizeof(b));
        m=s;
        s=s-1;
        a[0]='1';
        j=0;
        for(i=n-1;i>=0;i--)
        {
            if(s>9)
            {
                a[i]='9';
                s=s-9;
            }
            else
            {
                a[i]=a[i]+s;
                s=0;
            }
            if(m>9)
            {
                b[j]='9';
                m=m-9;
            }
            else
            {
                b[j]=b[j]+m;
                m=0;
            }
            j++;

        }
        a[n]='\0';
        b[n]='\0';
        printf("%s ",a);
         printf("%s\n",b);
         }
    }
    }
    return 0;
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值