#include <iostream>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <iterator>
#include <algorithm>
#include <functional>
#include <utility>
#include <sstream>
#include <climits>
#include <cassert>
#define MID(x,y) ( ( x + y ) >> 1 )
#define L(x) ( x << 1 )
#define R(x) ( x << 1 | 1 )
#define BUG puts("here!!!");
#define STOP system("pause");
using namespace std;
int main() {
int T;
cin >> T;
for(int i = 1; i <= T; i++) {
int a, b, left = 0, right = 0;
cin >> a >> b;
while(a > 1 || b > 1) {
if(a > b) {
int k = (a-1) / b;
left += k;
a = a - k * b;
} else {
int k = (b-1) / a;
right += k;
b = b - k * a;
}
}
printf("Scenario #%d:\n", i);
printf("%d %d\n", left, right);
}
return 0;
}
poj 2499 计算二叉树的“最短”路径 -> 贪心
最新推荐文章于 2022-11-17 09:20:12 发布