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

Find Its Place

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


Problem Description
Have you seen the National Day military review? That¡¯s very grand!
And now, ALPCs have received a arduous mission¡ª¡ªtaking a parade at August first.
The traditional order is rectangular, but ALPCs want to make a innovation. They start to research a new triangular order called Yang Hui¡¯s triangle.
Yang Hui¡¯s triangle is known to all:
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
In it the ends of each line is 1, and every other number in each line equals to the sum of the two numbers on the shoulders. It¡¯s obvious that it¡¯s a piece of cake (especially with the help of computer)for us to get value of the C-th number in line R, therefore our problem goes to the opposite: given two Continuous numbers in a same line, please find out their positions in this huge triangle.
 

Input
The first line of the input is a N indicating the test cases number.
Then follow N lines. Each line includes two positive integers: a, b, and a, b < 2^63. The number a should be aligned on the left of the number b. It¡¯s certain that for every data input there is always a solution.
 

Output
For each testing data there will be only one line out: R C. which means the C-th number on line R. What¡¯s more, R and C should be separated by a blank space. For multiple solutions, please print out the solution with the minimum R.
 

Sample Input
3 1 2 3 3 10 5
 

Sample Output
3 1 4 2 6 4
 

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:50:55, Gzip enabled