gcd 二进制/循环

#include<bits/stdc++.h>
#define LL long long
using namespace std;

inline aabs(LL x){
    return x>0?x:-x;}

inline LL gcd(LL a,LL n){
    if(a==0) return b;
    if(b==0) return a;
    if(!(a&1)&&!(b&1)) return 2*gcd(a>>1,b>>1);
    else if(!(a&1)) return gcd(a>>1,b);
    else if(!(b&1)) return gcd(a,b>>1);
    else return gcd(aabs(a-b),min(a,b));
}

 循环

inline int gcd(int a,int b){
    while(b!=0){int tmp=a%b;a=b;b=tmp;}return a;}

日后继续

posted @ 2018-09-29 09:37  ASDIC减除  阅读(179)  评论(0编辑  收藏  举报