Difference between revisions of "Wikipedia:Blakbord"

1,485 bytes added ,  11:20, 17 Marso 2019
walay mubong sugid sa pag-usab
m (Reverted edits by 109.175.86.199 (talk) to last revision by Vituzzu)
{{Please leave this line alone (sandbox heading)}}
<!-- Hello! Hala sige sulayi pagpormat ug pag-edit dinhi sa ubos aning pahibalo, ipakita ang imong pagkahanas sa pag-usab sa mga panid dinhi. Himoa unsay imong gusto dinhi. Dayon! -->
#include<bits/stdc++.h>
using namespace std;
//int oust=0;
typedef vector<long long>LL;
istream&operator>>(istream&in,LL&a)
{
a.clear();
string s;
cin>>s;
for(int i=0;i<s.size();++i)
{
a.push_back(s[s.size()-i-1]-'0');
}
return in;
}
ostream&operator<<(ostream&out,LL a)
{
for(int i=a.size()-1;i>=0;--i)cout<<a[i];
return out;
}
bool comp(LL&a,LL&b)
{
if(a.size()==b.size())
{
for(int i=b.size()-1;i>=0;--i)
{
if(a[i]==b[i])continue;
else return a[i]<b[i];
}
return 0;
}
return a.size()<b.size();
}
LL operator-(LL a,LL&b)
{
// cout<<a<<' '<<b<<' '<<oust<<endl;
// oust++;
// if(oust%20==0)cout<<oust<<" o\n";
LL c(0,0);
if(a==b)return c;
if(a.size()-b.size()>=2)
{
LL b2(a.size()-b.size()-1,0);
b2.insert(b2.end(),b.begin(),b.end());
return a-b2;
}
for(int i=0;i<min(a.size(),b.size());++i)a[i]-=b[i];
bool ok=0;
while(!ok)
{
ok=1;
for(int i=0;i<min(a.size(),b.size());++i)
{
if(a[i]<0){a[i]+=10;a[i+1]--;ok=0;}
}
}
while(!*--a.end())a.pop_back();
return a;
}
LL gcd(LL a,LL b)
{
if(a==b)return b;
while(b.size())
{
if(comp(a,b))swap(a,b);
LL a0=a,b0=b;
a=b0;
b=a0-b0;
}
return a;
}
int main()
{
// freopen("D:\\t.txt","r",stdin);
LL n,m;
cin>>n>>m;
cout<<gcd(n,m)<<endl;
return 0;
}
Anonymous user