标签:math return iostream int using 复杂度 复杂 ios ace
#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)
标签:math return iostream int using 复杂度 复杂 ios ace
原文地址:https://www.cnblogs.com/lcezych/p/10540620.html