CF 371B Fox Dividing Cheese[数论]】的更多相关文章

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…
题目链接 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…
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…
#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…
CF 980D Perfect Groups(数论) 一个数组a的子序列划分仅当这样是合法的:每个划分中的任意两个数乘积是完全平方数.定义a的权值为a的最小子序列划分个数.现在给出一个数组b,问权值为i的b的子串个数. 这题意真不是人类智慧能轻易描述的.据说此题在比赛场上读题30min,做题5min,做完还WA.果然是坑题. 如果有两个数a和b,a和b的乘积是完全平方数,那么如果a有因子x^2,那么x^2就可以去掉,使a变成a/x^2,结论依然成立.因此我们把所有数的质因子次数mod2,可以发现…
Fox Ciel is playing a mobile puzzle game called "Two Dots". The basic levels are played on a board of size n × m cells, like this: Each cell contains a dot that has some color. We will use different uppercase Latin characters to express differen…
题目链接:http://codeforces.com/contest/510/problem/C 题目大意:构造一个字母表,使得按照你的字母表能够满足输入的是按照字典序排下来. 递归建图:竖着切下来,将每个名字的第x个字母从上到下连接建图.然后求拓扑排序. 之所以要拓扑排序,因为要判断在x-1里面有a-->b  在x中有b-->a,这样就形成了一个环.这样一来,就不能够构造字母表了. [经验教训]:在递归建图的函数中开了两个数组,用来记录字母第一次出现和最后一次出现的位置..结果就RE在12上…
http://codeforces.com/contest/389/problem/E 题意:给你n个序列,然后两个人x,y,两个人玩游戏,x从序列的前面取,y从序列的后面取,两个人都想自己得到的数的和尽可能大,最后输出两个人得到的数的和. 思路:如果序列的个数为偶数的话,前面一半为x所得,后面一半为y所得: 如果为奇数的话,中间的数根据它的大小决定谁得到.这样的处理方式因为两个人都尽可能的取得序列中的最大,在谁的那一半数大的,另一个人取不到,有的时候可以先放一放,去取别人即将取到的数. #in…