题目链接 Fox Dividing Cheese 思路:求出两个数a和b的最大公约数g,然后求出a/g,b/g,分别记为c和d. 然后考虑c和d,若c或d中存在不为2,3,5的质因子,则直接输出-1(根据题目要求) 计算出c = (2 ^ a2) * (3 ^ a3) * (5 ^ a5)      d = (2 ^ b2) * (3 ^ b3) * (5 ^ b5) 那么答案就是a2 + a3 + a5 + b2 + b3 + b5 #include <bits/stdc++.h> usin…
#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); } retur…
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The be…
Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The bears are so greedy that they are ready to fight for the larger piece. That's where the fox comes in and starts the dialog: "Little be…
B. Fox Dividing Cheese time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Two little greedy bears have found two pieces of cheese in the forest of weight a and b grams, correspondingly. The be…
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 m1,m2; int check(ll x) { while(x) { ==) x/=; ==) x/=; ==) x…
https://codeforces.com/problemset/problem/773/A 一开始二分枚举d,使得(x+d)/(y+d)>=p/q&&x/(y+d)<=p/q,错在这些数是离散的,不能由两边异号判定一定存在这个交点. 然后改成枚举d,使得y=d*q,这样就一定是倍数了.然后就是要想清楚了,找不到这样卡在中间的d,其实都是因为d不够大的原因,d够大保证是可以的除非正确率是100%. 然后就是二分的上界,按道理q的最大值是1e9,y的最大值也是1e9,他们的公倍…
http://codeforces.com/problemset/problem/346/A 观察了一下,猜测和他们的最大公因数有关,除以最大公因数前后结果是不会变的. 那么怎么证明一定是有n轮呢?我猜就是因为现在至少有几个是互质的,所以总是可以构造出1?具体怎么证明呢?还是看看别人的思路吧…… 首先最终停止的状态一定是一个等差数列,这个是毫无疑问的.设首项为d,那么肯定停止于d,2d,3d,...,n,那么很显然d就是他们的最大公因数啊……对哦?! #include<bits/stdc++.h…
题目大意:输入一个整数n,输出使2^x mod n = 1成立的最小值K 解题思路:简单数论 1)n可能不能为偶数.因为偶数可不可能模上偶数以后==1. 2)n肯定不可能为1 .因为任何数模上1 == 0: 3)所以n肯定是除1外的奇数 代码如下: #include <iostream> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ if(n == 1 || n % 2 ==…
Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. Polycarp painted some of cells with black, the others remained white. Inspired by Malevich's "Black Square", Polycarp wants to paint minimum pos…