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 |
TLE------>0s(附代码)#include<iostream> using namespace std; int main() { int left,right,a,b,n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d%d",&a,&b); left=0;right=0; while(!(a==1&&b==1)) { if(a>b) { int t; if(b==1)t=a-b; else t=a/b; left+=t; a-=t*b; } if(a<b) { int t; if(a==1)t=b-a; else t=b/a; right+=t; b-=t*a; } } printf("Scenario #%d:\n",i); printf("%d %d\n\n",left,right); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator