/*
* POJ_2499.cpp
*
* Created on: 2013年11月6日
* Author: Administrator
*/
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
int t;
scanf("%d",&t);
int counter = 1;
while(t--){
int a,b;
scanf("%d%d",&a,&b);
int left =0;
int right = 0;
while(a>1||b>1){
if(a>b){
int up = (a-1)/b;//向左走(a-1)/b步
left+=up;
a -= up*b;
}else{
int up = (b-1)/a;
right += up;
b -= up*a;
}
}
printf("Scenario #%d:\n",counter++);
printf("%d %d\n\n",left,right);
}
return 0;
}
(计算二叉树的路径9.2.1)POJ 2499 Binary Tree(走到根节点需要向左走向右走多少步)
最新推荐文章于 2021-07-31 11:52:43 发布