0分,全部MLE,不知道为什么
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN = 1e4 + 5;
struct Big_Int{
string s;
int a[MAXN];
void read(){cin >> s;}
void print(){
for(int i = a[0];i >= 1;--i) cout << a[i];
cout << endl;
}
void zhuan(){
a[0] = s.size();
for(int i = s.size() - 1;i >= 0;--i) a[s.size() - i] = s[i] - '0';
}
void scan(){
read();
zhuan();
}
};
bool operator<(Big_Int x,Big_Int y){
if(x.a[0] != y.a[0]) return x.a[0] < y.a[0];
for(int i = x.a[0];i >= 1;--i)
if(x.a[i] != y.a[i]) return x.a[i] < y.a[i];
}
bool operator==(Big_Int x,Big_Int y){
if(x.a[0] != y.a[0]) return 0;
for(int i = x.a[0];i >= 1;--i)
if(x.a[i] != y.a[i]) return 0;
return 1;
}
bool operator>(Big_Int x,Big_Int y){
return !(x < y) && !(x == y);
}
bool operator>=(Big_Int x,Big_Int y){
return !(x < y);
}
bool operator<=(Big_Int x,Big_Int y){
return !(x > y);
}
bool operator!=(Big_Int x,Big_Int y){
return !(x == y);
}
Big_Int operator-(Big_Int x,Big_Int y){
Big_Int ans;
ans.a[0] = max(x.a[0],y.a[0]);
for(int i = 1;i <= ans.a[0];++i){
while(x.a[i] < y.a[i]) x.a[i] += 10,x.a[i + 1]--;
ans.a[i] = x.a[i] - y.a[i];
}
while(ans.a[ans.a[0]] == 0 && ans.a[0] != 1) ans.a[0]--;
return ans;
}
Big_Int operator*(Big_Int x,int y){
Big_Int ans;
int t = 0;
ans.a[0] = x.a[0];
for(int i = 1;i <= x.a[0];++i){
ans.a[i] = x.a[i] * y + t;
t = ans.a[i] / 10,ans.a[i] %= 10;
}
while(t) ans.a[++ans.a[0]] = t % 10,t /= 10;
return ans;
}
Big_Int operator/(Big_Int x,int y){
Big_Int ans;
int r = 0;
ans.a[0] = x.a[0];
for(int i = x.a[0];i >= 1;--i){
r = r * 10 + x.a[i];
ans.a[i] = r / y,r %= y;
}
while(ans.a[ans.a[0]] == 0 && ans.a[0] != 1) ans.a[0]--;
return ans;
}
Big_Int max(Big_Int x,Big_Int y){
if(x > y) return x;
else return y;
}
Big_Int min(Big_Int x,Big_Int y){
if(x < y) return x;
else return y;
}
Big_Int gcd(Big_Int x,Big_Int y){
if(y.a[0] == 1 && y.a[1] == 0) return x;
else if(x.a[0] == 1 && x.a[1] == 0) return y;
else if(x.a[1] % 2 == 0 && y.a[1] % 2 == 0){
int cnt = 0;
while(x.a[x.a[0]] % 2 == 0 && y.a[y.a[0]] % 2 == 0){
cnt++;
x = x / 2,y = y / 2;
}
Big_Int ans = gcd(x,y);
for(int i = 1;i <= cnt;++i) ans = ans * 2;
return ans;
}
else if(x.a[1] % 2 == 0){
while(x.a[1] % 2 == 0) x = x / 2;
return gcd(x,y);
}
else if(y.a[1] % 2 == 0){
while(y.a[1] % 2 == 0) y = y / 2;
return gcd(x,y);
}
else{
Big_Int a = max(x,y),b = min(x,y);
return gcd(a - b,b);
}
}
int main(){
ios::sync_with_stdio(false);
Big_Int a,b;
a.scan(),b.scan();
Big_Int ans = gcd(a,b);
ans.print();
return 0;
}