#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)
原文地址:https://www.cnblogs.com/lcezych/p/10540620.html
时间: 2024-11-07 10:47:19