#include<stdio.h>

int count;

int gcd(int a,int b) {

if(b==0)

return a;

    return gcd(b,a%b);

}

int seach(int a) {

if(a%2==0) {

count++;

return seach(a/2);

}

if(a%3==0) {

count++;

return seach(a/3);

}

if(a%5==0) {

count++;

return seach(a/5);

}

return a;

}

int main() {

int n,m,i,j,k,a,b,counta,countb,flag,sum;

while(scanf("%d%d",&n,&m)!=EOF) {

if(n==m) {

printf("0\n");

continue;

}

  k=gcd(n,m);

   a=n/k;

b=m/k;

flag=0;

count=0;sum=0;

   counta=seach(a);

sum+=count;

count=0;

countb=seach(b);

sum+=count;

if(counta==1&&countb==1)

printf("%d\n",sum);

else

printf("-1\n");

}

return 0;

}

codeforces 371B - Fox Dividing Cheese的更多相关文章

  1. 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( ...

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

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

  3. 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 ...

  4. 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 ...

  5. cf B. Fox Dividing Cheese

    http://codeforces.com/contest/371/problem/B #include <cstdio> #include <iostream> #inclu ...

  6. CodeForces 388A Fox and Box Accumulation (模拟)

    A. Fox and Box Accumulation time limit per test:1 second memory limit per test:256 megabytes Fox Cie ...

  7. Codeforces 388C Fox and Card Game (贪心博弈)

    Codeforces Round #228 (Div. 1) 题目链接:C. Fox and Card Game Fox Ciel is playing a card game with her fr ...

  8. codeforces 510B. Fox And Two Dots 解题报告

    题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...

  9. Codeforces 388A - Fox and Box Accumulation

    388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...

随机推荐

  1. Elementui tabs组件内添加组件

    1. Elementui tabs组件内添加组件 1.1. 需求 今天的一个需求是在后台框架的基础上添加tab页,结果页面如下 原本上述红框内的内容是不存在的,直接点击左侧菜单栏进行页面跳转,现加了t ...

  2. xshell、xftp最新版下载方法

    https://www.netsarang.com/download/main.html 登录邮箱打开第一个下载地址进行下载

  3. [C++ STL] 各容器简单介绍

    什么是STL? 1.STL(Standard Template Library),即标准模板库,是一个高效的C++程序库. 2.包含了诸多常用的基本数据结构和基本算法.为广大C++程序员们提供了一个可 ...

  4. jquery中有关cookie的使用简要说明

    jquery.cookie.js 的配置 首先包含jQuery的库文件,在后面包含 jquery.cookie.js 的库文件. <script type="text/javascri ...

  5. 获取Spring容器中的Bean协助调试

    在使用Spring进行开发时,有时调bug真的是很伤脑筋的一件事,我们可以通过自定义一个监听器来获取Spring容器中的Bean实例来协助我们调试. 第一步:编写自定义监听器 /** * 监听serv ...

  6. CF814C An impassioned circulation of affection

    思路: 对于题目中的一个查询(m, c),枚举子区间[l, r](0 <= l <= r < n),若该区间满足其中的非c字符个数x不超过m,则可以将其合法转换为一个长度为r-l+1 ...

  7. cocos2dx在windows下搭建环境android报错

    报错:Program bash is not found in PATH   (如果按照我的方法来的话是没有这个错误的,我之前用别的方法的时候有但是后来还是没解决,写出来放到这里做参考吧) 参考原文: ...

  8. Django--4、认证系统

    cookie与session 概念 因http协议无法保存状态,但是又需要保存状态,所以有了cookie.它不属于http协议范畴 工作原理:相当于一段标识数据.在访问服务器产生标识内容(cookie ...

  9. 盒子模型,top和margin-top

    1. 标准盒子模型: width只是内容的宽度. 元素的总宽度=width + padding*2 +border*2 +margin*2. IE盒子模型: width=内容的宽度 + padding ...

  10. 部署bugzilla(bugzilla+apache+mysql+linux)

    工作原因,需要部署bugzilla.在此,容我新造个轮子.官方轮子:https://bugzilla.readthedocs.org/en/latest/installing/quick-start. ...