思路:一步一步往上走即可
#include<iostream>
using namespace std;
int main()
{
int sc;
cin>>sc;
for(int s=1;s<=sc;s++)
{
int a,b;
cin>>a>>b;
int left=0,right=0;
while(1)
{
if(a>b)
{
int up=(a-1)/b;
//int up=a/b;
left+=up;
a-=up*b;
}
else
{
int up=(b-1)/a;
//int up=b/a;
right+=up;
b-=up*a;
}
if(a==1 &&b==1)
break;
}
cout<<"Scenario #"<<s<<":"<<endl;
cout<<left<<" "<<right<<endl<<endl;
}
return 0;
}