cf B. Fox Dividing Cheese

http://codeforces.com/contest/371/problem/B

 #include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
#define ll int
using namespace std; ll a,b;
int ans=;
int m1,m2;
int check(ll x)
{
while(x)
{
if(x%==)
x/=;
else if(x%==)
x/=;
else if(x%==)
x/=;
else
{
break;
}
ans++;
}
return x;
} ll gcd(ll c,ll d)
{
return d==?c:gcd(d,c%d);
} int main()
{
cin>>a>>b;
if(a==b)
{
printf("0\n");
return ;
}
int s=gcd(a,b);
a/=s;
b/=s;
if(check(a)==check(b))
{
printf("%d\n",ans);
}
else printf("-1\n");
return ;
}
上一篇:【Linux 命令】Linux系统下强制用户下线——who,pkill


下一篇:写个 Hello World 而已,要不要这么震撼?!