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);
}
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的更多相关文章
- 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( ...
 - CF 371B Fox Dividing Cheese[数论]
		
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...
 - 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 ...
 - 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 ...
 - cf B. Fox Dividing Cheese
		
http://codeforces.com/contest/371/problem/B #include <cstdio> #include <iostream> #inclu ...
 - 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 ...
 - 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 ...
 - codeforces  510B. Fox And Two Dots  解题报告
		
题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易 ...
 - Codeforces 388A - Fox and Box Accumulation
		
388A - Fox and Box Accumulation 思路: 从小到大贪心模拟. 代码: #include<bits/stdc++.h> using namespace std; ...
 
随机推荐
- 推荐一波 瀑布流的RecylceView
			
推荐博客:http://www.bubuko.com/infodetail-999014.html
 - CentOS环境下下调整home和根分区大小
			
项目建设方给提供了3台CentOS的服务器,连接进去之后发现磁盘空间很大,但是都放在了home目录下,所以需要调整一下. 1.查看磁盘使用情况 [root@CentOS ~]# df -h Files ...
 - Spring Cloud学习(一)
			
SpringCloud是什么? Spring Cloud是一个微服务框架,相比Dubbo等RPC框架, Spring Cloud提供的全套的分布式系统解决方案. Spring Cloud对微服务基础框 ...
 - SVN版本库的备份及迁移
			
备份某个版本库:打开控制台窗口 1.备份某个版本库: svnadmin dump myrepos > dumpfile //将指定的版本库导出成文件dumpfile eg:svnadmin du ...
 - 通信协议------Http、TCP、UDP
			
CP HTTP UDP: 都是通信协议,也就是通信时所遵守的规则,只有双方按照这个规则“说话”,对方才能理解或为之服务. TCP HTTP UDP三者的关系: TCP/IP是个协议组, ...
 - Python之Pandas中Series、DataFrame实践
			
Python之Pandas中Series.DataFrame实践 1. pandas的数据结构Series 1.1 Series是一种类似于一维数组的对象,它由一组数据(各种NumPy数据类型)以及一 ...
 - NX自动出图 (更新啦)
			
1.创建模板类零件图纸 2.创建顶针类零件图纸 3.创建镶件类零件图纸 4.自动创建孔表
 - 【译】x86程序员手册23-6.5组合页与段保护
			
6.5 Combining Page and Segment Protection 组合页与段保护 When paging is enabled, the 80386 first evaluates ...
 - 【alert(1) to win】不完全攻略
			
alert(1) to win 一个练习XSS的平台,地址:https://alf.nu/alert1 Warmup 给出了一段JavaScript代码 function escape(s) { re ...
 - MySql(四)Select条件查询
			
select条件查询的格式如下: SELECT 查询列表FROM 表名WHERE 筛选条件:123456根据筛选条件可以分为以下几类: 按照条件按表达式进行筛选 常用条件运算符如下:> .< ...