cf B. Fox Dividing Cheese
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的更多相关文章
- CF 371B Fox Dividing Cheese[数论]
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standa ...
- 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 ...
- 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( ...
- 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 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); ...
- CF 510b Fox And Two Dots
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on ...
- [CF #290-C] Fox And Names (拓扑排序)
题目链接:http://codeforces.com/contest/510/problem/C 题目大意:构造一个字母表,使得按照你的字母表能够满足输入的是按照字典序排下来. 递归建图:竖着切下来, ...
- cf E. Fox and Card Game
http://codeforces.com/contest/389/problem/E 题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的 ...
- cf C. Fox and Box Accumulation
题意:输入一个n,然后输入n个数,问你可以划分多少个序列,序列为:其中一个数为c,在它的前面最多可以有c个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...
随机推荐
- 史上最全maven pom.xml详解
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- jvm之内存分配与回收策略
1.java堆中各代分布 (1)Young:主要是用来存放新生的对象. (2)Old:主要存放应用程序中生命周期长的内存对象. (3)Permanent:是指内存的永久保存区域,主要存放Class和M ...
- Sublime Text 常用快捷键
/* 之前用过的好多的编辑器,从IT大牛们的博客里知道了他们所谓的Vim,Vi,Emacs等,也都挨个装上试了,不尽人意,但自从遇到了Sublime Text,甚是喜欢,有道是“情不知何而起,一往而深 ...
- jQuery 對table的基本操作
一.鼠标移动到行更换背景色: css样式: .hover{ background-color: #cccc00; } Js脚本: $(document).ready(function () { //鼠 ...
- Ubuntu12.04下使用valgrind内存测试工具测试Qt程序
1. 到官网http://valgrind.org/downloads/上下载valgrind最新版本: 2. 解压源码,执行./configure;make;make install后,默认安装到/ ...
- codevs 1269 匈牙利游戏
/*暴力+乱搞 55分(似乎只有暴力得分了)*/ #include<iostream> #include<cstdio> #include<cstring> #in ...
- PLSQL编程基础
一 PL/SQL简介 1 SQL:结构化的查询语句 2 PL/SQL优点与特性: 提高运行效率==>>提高运行效率的其他方式(存储过程,分页,缓存,索引) 模块化设计 允许定义标识符(变量 ...
- HTML5和CSS3实例教程[总结一]
关于onclick的行为与内容分离 通过链接触发弹出窗口方式 (不推荐使用此方法!!!) <a href='#' onclcik = "window.open('holiday_pay ...
- spring通过注解依赖注入和获取xml配置混合的方式
spring的xml配置文件中某个<bean></bean>中的property的用法是什么样的? /spring-beans/src/test/java/org/spring ...
- linux下查看已经安装的jdk 并卸载jdk
一.查看Jdk的安装路径: whereis javawhich java (java执行路径)echo $JAVA_HOME echo $PATH 备注:如果是windows中,可以使用: set j ...