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个数. 思路:先排序,然后对于每一个数逐步的找没有被用过的数,且这个数可以符合条件,然后如果没有 ...
随机推荐
- java文件(文件夹)操作
java中文件操作 判断是否为文件file.isFile()方法 判断是否为目录file.isDirectory()方法 判断是否存在file.exist()方法 创建新文件file.createNe ...
- hdu3656Fire station(DLX重复覆盖 + 二分)
题目请戳这里 题目大意:一个城市n个点,现在要建m个消防站,消防站建在给定的n个点中.求建m个消防站后,m个消防站要覆盖所有的n个点的覆盖半径最小. 题目分析:重复覆盖问题,DLX解决.不过要求覆盖半 ...
- 状压dp-poj-1170-Shopping Offers
题目链接: http://poj.org/problem?id=1170 题目意思: 购物车里有b种(0=<b<=5)物品,每种物品告诉物品代号c(1=<c<=999),数量为 ...
- Git详解之一 Git起步
起步 本章介绍开始使用 Git 前的相关知识.我们会先了解一些版本控制工具的历史背景,然后试着让 Git 在你的系统上跑起来,直到最后配置好,可以正常开始开发工作.读完本章,你就会明白为什么 Git ...
- 关于C#泛型列表List<T>的基本用法总结
//示例代码如下:using System;using System.Collections.Generic;using System.Collections.ObjectModel;namespac ...
- HUNNU--湖师大--11410--Eligibility
[I] Eligibility Regional Contest Director Osama Ismail knows that an individual cannot participate i ...
- [Javascript] JavaScript Array Methods in Depth - push
Array push is used to add elements to the end of an Array. In this lesson we'll see how the push met ...
- UML解惑:图说UML中的六大关系--转
UML定义的关系主要有六种:依赖.类属.关联.实现.聚合和组合.这些类间关系的理解和使用是掌握和应用UML的关键,而也就是这几种关系,往往会让初学者迷惑.这里给出这六种主要UML关系的说明和类图描述, ...
- Cortex依赖管理
cortex中文博客链接: http://cnblog.ctx.io/post/91333512673/cortex 关于cortex项目, 参见项目主页: http://ctx.io 项目在gith ...
- javascript !!的作用是把一个其他类型的变量转成的bool类型
!!的作用是把一个其他类型的变量转成的bool类型