#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. 开车旅行 2012年NOIP全国联赛提高组(倍增+set)

    开车旅行 2012年NOIP全国联赛提高组  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond     题目描述 Description 小A 和小B决定利用 ...

  2. 贪心 HDOJ 5355 Cake

    好的,数据加强了,wa了 题目传送门 /* 题意:1到n分成m组,每组和相等 贪心:先判断明显不符合的情况,否则肯定有解(可能数据弱?).贪心的思路是按照当前的最大值来取 如果最大值大于所需要的数字, ...

  3. protobuf的lua版

    推荐个protobuf的lua版     以前项目客户端lua,通信协议是protobuf,用网易的proto-gen-lua,使用过程遇到些问题需要绕,比如: 1.每次更改.增加proto都要生成新 ...

  4. web安全测试--XSS(跨站脚本)与CSRF

    XSS攻击原理 反射型 发出请求时,xss代码出现在URL中,作为输入提交到服务器端,服务器端解析后响应,xss代码随响应内容一起传回浏览器,最后浏览器解析执行xss代码.这个过程像一次反射,故叫反射 ...

  5. 联想 Z5S(L78071)免解锁BL 免rec 保留数据 ROOT Magisk Xposed 救砖 ZUI 10.5.370

    >>>重点介绍<<< 第一:本刷机包可卡刷可线刷,刷机包比较大的原因是采用同时兼容卡刷和线刷的格式,所以比较大第二:[卡刷方法]卡刷不要解压刷机包,直接传入手机后用 ...

  6. Android Studio 1.5启动出现“SDK Manager: failed to install”问题的解决

    问题描述 Android Studio 1.5是当前最新Android手机应用开发平台,下载bundle版安装后,启动Studio后出现“SDK Manager: failed to install” ...

  7. TI 77GHZ雷达开发套件 RDP-DC100

                                        RDP-DC100用户使用手册           目录 1.      硬件说明... 3 1.1.      官方处理板的修 ...

  8. linux使用crontab实现PHP执行计划定时任务

    linux使用crontab实现PHP执行计划定时任务 前几天写过一篇文章,利用单纯的php实现定时执行任务,但是效率不佳,对于linux来说用crontab实现更加合理 首先说说cron,它是一个l ...

  9. windows如何统计端口的连接数

    习惯了linux的系统管理员,对linux的命令行工具总是印象极深,几乎所有的管理都可以在命令行下完成.命令行工具是linux系统管理的主流. 而使用windows是,因为图形化的界面,大家习惯了图形 ...

  10. 09C语言指针

    C语言指针 地址 地址就是数据元素在内存中的位置表示: &变量名 #include <stdio.h> int main(){ int aa; unsigned int bb = ...