//位运算求解最大公约数 longlonggcd(longlong a,longlong b) { if(a<b) returngcd(b,a); if(b==0) return a; if((a&1)==0&&(b&1)==0) return2*gcd(a>>1,b>>1);//a and b are even if((a&1)==0) returngcd(a>>1,b); // only a is even if((b&1)==0) returngcd(a,b>>1); // only b is even returngcd((a+b)>>1,(a-b)>>1); // a and b are odd }