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 ;
}

cf B. Fox Dividing Cheese的更多相关文章

  1. CF 371B Fox Dividing Cheese[数论]

    B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...

  2. Codeforces Round #218 (Div. 2) B. Fox Dividing Cheese

    B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...

  3. Codeforces 371B Fox Dividing Cheese(简单数论)

    题目链接 Fox Dividing Cheese 思路:求出两个数a和b的最大公约数g,然后求出a/g,b/g,分别记为c和d. 然后考虑c和d,若c或d中存在不为2,3,5的质因子,则直接输出-1( ...

  4. Codeforces 371BB. Fox Dividing Cheese

    Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, corre ...

  5. codeforces 371B - Fox Dividing Cheese

    #include<stdio.h> int count; int gcd(int a,int b) { if(b==0) return a;     return gcd(b,a%b); ...

  6. CF 510b Fox And Two Dots

    Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on ...

  7. [CF #290-C] Fox And Names (拓扑排序)

    题目链接:http://codeforces.com/contest/510/problem/C 题目大意:构造一个字母表,使得按照你的字母表能够满足输入的是按照字典序排下来. 递归建图:竖着切下来, ...

  8. cf E. Fox and Card Game

    http://codeforces.com/contest/389/problem/E 题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的 ...

  9. cf C. Fox and Box Accumulation

    题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...

随机推荐

  1. oracle管道输出

    通常我们会在oracle中用dbms_output输出调试信息,但dbms_output只能在调用过程完成才返回结果,不能实时输出的.这意味着通常我们经常要等几分钟或更长的时间才能看到调试信息,那怎么 ...

  2. HDU1863 畅通project 【最小生成树Prim】

    畅通project Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. [Javascript] Array methods in depth - filter

    Array filter creates a new array with all elements that pass the test implemented by the provided fu ...

  4. 查看linux版本号的几种方法

    (1)lsb_release 命令查看,FSG(Free Standards Group)组织开发的LSB (Linux Standard Base)标准的一个命令,用来查看linux兼容性的发行版信 ...

  5. Pascal&#39;s Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  6. unity3d Find()使用

    1. Hierarchy 创建对象如两个cube时,未修改名称,名称都为cube时. js添加至Camera: private var cubeObj : GameObject; //private ...

  7. 斐波那契数列(fabnacci)java实现

    斐波那契数列定义:From Wikipedia, the free encyclopedia http://en.wikipedia.org/wiki/Fibonacci_number In math ...

  8. SVN 中trunk、tags、branches使用

    简介 我们都知道SVN是管理项目源代码的软件,可以把我们开发中的各个阶段的代码记录下来,供我们以后来使用,那么SVN具体的结构你是否知道呢?下面我们来介绍一下它的基本结构 Trunk.Branches ...

  9. Managing linux Shell Jobs

    Managing Shell Jobs   When moving jobs between the foreground and background, it may be useful to ha ...

  10. 退出应用 关闭多个Activity

    Activity3 public class Activity3 extends ListActivity {     protected void onCreate(Bundle savedInst ...