Playing with Paper CodeForces – 527A

http://codeforces.com/problemset/problem/527/A

求GCD,答案是每次加上a/b;

#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
typedef long long ll;
ll ans=0;
ll gcd(ll a,ll b)
{
	if(b==0) 
	{
		return a;	
	}
	else
	{
		ans+=a/b;
		return gcd(b,a%b);
	}
}
ll aa,bb;
int main()
{
	scanf("%lld%lld",&aa,&bb);
	gcd(aa,bb);
	printf("%lld",ans);
} 

 

发表评论

邮箱地址不会被公开。 必填项已用*标注