Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
好巧,我也是100题,贴个代妈喵~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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator