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

进来看下,比较简练的写法

Posted by KatrineYang at 2016-11-12 14:57:57 on Problem 1597 and last updated at 2016-11-12 14:59:07
#include <stdio.h>
int gcd(int n, int m){
	n=(n>0)?n:-n;
	m=(m>0)?m:-m;
	if(!n)return m;
	if(!m)return n;
	if(n>m)return gcd(m,n%m);
	return gcd(n,m%n);
}

int main() {
	int n,m;
	while(scanf("%d%d",&n,&m)>0){
		printf("%10d%10d    %sd Choice\n\n", n,m,(gcd(n,m)^1)?"Ba":"Goo");
	}
	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