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

Re:3 2的时候谁赢?

Posted by yuanyirui at 2007-06-07 01:12:43 on Problem 2348
In Reply To:3 2的时候谁赢? Posted by:yuanyirui at 2007-06-07 01:03:48
按照两位牛人写的程序,对3 2判的完全不同,竟然都过了...无语
// 第一种
#include <stdio.h>
int main()
{
	int n,m,r,k,a[1000];
	while(scanf("%d %d",&n,&m)==2)
    {
		if(n==0&&m==0) break;
		if(n<m){
			int temp=n;
			n=m;
			m=temp;
		}
		
		k=0;
		do{
			a[k++]=n/m;
			r=n%m;
			n=m;
			m=r;
		}while(r!=0);
		int i,num=0;
		
		for(i=0;i<k;i++){
			if(a[i]==1)
				num++;
			else break;
		}
		if(num==k){
			if(num%2==1) printf("Stan wins\n");
			else printf("Ollie wins\n");
		}
		else{
			if(num%2==0) printf("Stan wins\n");
			else printf("Ollie wins\n");
		}
	}
	return 0;
}
// 第二种
#include <stdio.h>
#define gold 1.618034
int main()
{
   // freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    int n,m,tmp;
    while(scanf("%d%d",&n,&m),n||m){
        if(n<m)tmp=n,n=m,m=tmp;
        if(n==m || n>m*gold) printf("Stan wins\n");
        else printf("Ollie wins\n");
    }
    return 1;
}

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