描述:
A continued fraction is an expression of the form:
a0+1a1+1a2+1⋱+1ana0+1a1+1a2+1⋱+1an
where a0,a1,…,ana0,a1,…,an are nonnegative integers.
Given a fraction xyxy(x,yx,y are positive integers), please expand it into a continued fraction.
输入:
The first line contains an integer T(1≤T≤103)T(1≤T≤103), denoting the number of test cases.
The only line of each test case contains two integers x,y(1≤x,y≤109)x,y(1≤x,y≤109), denoting a fraction xyxy. It's guaranteed that gcd(x,y)=1gcd(x,y)=1.
输出:
For each test case, output one line: first an integer nn denoting the height of the continued fraction, then n+1n+1 integers denoting a0,…,ana0,…,an. Your solution should gurarantee that 0≤n≤1000,0≤ai≤1090≤n≤1000,0≤ai≤109.
If there are multiple valid solutions, you only need to output one of them.
翻译:连分数有一下形式,其中a0,a1...an为非负整数.给定一个分数x/y(x,y都为正整数),将他们以连分数的形式表示.
输入:第一行为一个整数T(1<=T<=10E3),代表测试样例数.每个测试样例一行,两个整数x,y(1<=x,y<=10E9).代表一个分数x/y,并且保证x和y最大公约数为1.
输出:每个测试样例一行,第一个整数n代表的连分数的长度.然后n+1个整数标记为a0...an你的方案应该保证0<=n<=1000,0<=ai<=10E9.
如果有多种解决方案,你只需要输出其中一个