Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

好巧,我也是100题,贴个代妈喵~

Posted by KatrineYang at 2016-07-11 20:44:46 on Problem 2499 and last updated at 2016-07-11 20:44:56
In Reply To:100题,纪念~~~~ Posted by:swust20051578 at 2007-10-22 09:09:19
喵喵~
#include <iostream>
using namespace std;

class zuoyou{
public:
	int zuo;
	int you;
	zuoyou(int z, int y): zuo(z), you(y){}
	zuoyou(): zuo(0), you(0){}
};

zuoyou jisuan(int x, int y){
	if(x == 1) return zuoyou(0, y-1);
	if(y == 1) return zuoyou(x-1, 0);
	if(x > y){
		zuoyou temp = jisuan(x%y, y);
		return zuoyou(x/y + temp.zuo, temp.you);
	}
	else{
		zuoyou temp = jisuan(x, y%x);
		return zuoyou(temp.zuo, y/x + temp.you);
	}
}

int main() {
	int cases;
	cin >> cases;
	for(int i = 0; i < cases; i++){
		cout << "Scenario #" << i+1 << ":\n";
		int x, y;
		cin >> x >> y;
		zuoyou res = jisuan(x, y);
		cout << res.zuo << " " << res.you << endl << endl;
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator