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; ...
随机推荐
- bzoj2093: [Poi2010]Frog(单调队列,倍增)
2093: [Poi2010]Frog Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 568 Solved: 186[Submit][Status] ...
- python实现对某招聘网接口测试获取平台信息
"""通过接口测试的技术获取某招聘网平台的资料"""url = "https://www.lagou.com/jobs/posit ...
- Kafka详解与总结(七)-Kafka producer拦截器(interceptor)
1. 拦截器原理 Producer拦截器(interceptor)是在Kafka 0.10版本被引入的,主要用于实现clients端的定制化控制逻辑. 对于producer而言,interceptor ...
- G - And Then There Was One (约瑟夫环变形)
Description Let’s play a stone removing game. Initially, n stones are arranged on a circle and numbe ...
- 61配置nanopim1plus的HDMI为1080p输出
61配置nanopim1plus的HDMI为1080p输出 大文实验室/大文哥 壹捌陆捌零陆捌捌陆捌贰 21504965 AT qq.com 完成时间:2018/4/4 10:21 版本:V1.1 开 ...
- C语言调用Python
python模块:demo.py def print_arg(str): print str def add(a,b): print 'a=', a print 'b=', b return a + ...
- UVM基础之---------uvm factory机制base
从名字上面就知道,uvm_factory用来制造uvm_objects和component.在一个仿真过程中,只有一个factory的例化存在. 用户定义的object和component types ...
- Spartan6系列之SelectIO深入详解及高级应用简介
1. 什么是I/O Tile? 对Spartan-6系列FPGA来说,一个IO Tile包括2个IOB.2个ILOGIC.2个OLOGIC.2个IODELAY. 图 1Spartan-6系列 ...
- HDU_1074_Doing Homework_状态压缩dp
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1074 Doing Homework Time Limit: 2000/1000 MS (Java/Othe ...
- Django基础核心技术之Model模型的介绍与设计
Django基础核心技术之Model模型的介绍与设计原创: Yunbo Shi Python Web与Django开发 2018-05-03Django网络应用开发的5项基础核心技术包括模型(Mode ...