#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
using namespace std;
int a,b;
int gcd(int a,int b)
{
    if(b==0) return a;
    else return gcd(b,a%b);
}
int main()
{
    cin>>a>>b;
    cout<<gcd(a,b);
    return 0;
}

对于任意a,b∈N, b≠0,gcd(a,b)=gcd(b,a mod b)

复杂度 O(log(a+b)

相关文章:

  • 2021-11-27
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-07
  • 2022-12-23
猜你喜欢
  • 2021-11-01
  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2021-09-08
  • 2022-12-23
  • 2021-10-18
相关资源
相似解决方案