equal numbers】的更多相关文章

传送:http://codeforces.com/gym/101612 题意:给出一个大小为n的序列a[i],每次选其中一个数乘以一个正整数,问进行k步操作后最少剩下多少种数字,输出0≤k≤n,所有的k的答案. 注意这k步不一定是连续的. 分析: 对于每个数,可以有两种操作: 1. 先将有倍数的数变成它们的最大倍数,而且按照出现次数比较少的先变. 2. 将所有数都变成lcm,而且按照出现次数比较少的先变. 数组f[i]代表,操作i次的最小种类数.对于每一次操作,取min. #include<bi…
题目链接 \(Description\) 给定\(n\)个数,每次可以将任意一个数乘上任意一个正整数. 求\(k\)次操作后,数列中数的种类最少可以是多少.对每个\(0\leq k\leq n\)输出答案. \(n\leq 3\times10^5,a_i\leq10^6\). \(Solution\) 有两种贪心策略,一是每次找一个出现次数最少的数,把它变成所有数的LCM:二是找一个出现次数最少,且它的某个倍数存在于原数列里的数,将它变成它的这个倍数. 对两种情况取\(\min\)即可. //9…
给你一个n长度的数组,让你修改0到n次,问每次修改后能剩下不同个数的最小数是多少: 这里有了两种做法,一种是变成他们的lcm这样的话,修改后答案应该是减去改过的个数然后在加一 另一种就是数字修改成序列中的倍数,比如如果序列中有4和8,修改一次把4变成8,这样剩下的数字就只有一个:比较这两个做法,找出更小的就好了 做法就是,一种把原来次数从小到大排序,然后一个个变,另一种就是把能变成序列中其他数字的数的个数从小到大排,然后一次次跑就可以了 #include<bits/stdc++.h> #def…
题意: 给你n个数vi,你有k次操作.每一次操作你可以从n个数里面挑一个数,然后使得这个数乘于一个正整数.操作完之后,这n个数里面不同数的数量就是权值.你要使得这个值尽可能小. 题解: 如果a%b==0 && a!=b b%c==0 && b!=c 那么如果我们进行操作的话,肯定是把c变成a,因为这样消耗的最小操作数最少 我们最后的答案只需要在两种情况中取最小值就可以了 1.我们把n个数都往n个数的公倍数上变 2.如果这n个数里面出现了上面所示的a.b.c的情况,那么我们就…
题目链接: 传送门 Berland Bingo time limit per test:1 second     memory limit per test:256 megabytes Description Lately, a national version of a bingo game has become very popular in Berland. There are n players playing the game, each player has a card with…
Description There are two rows of positive integer numbers. We can draw one line segment between any two equal numbers, with values r, if one of them is located in the first row and the other one is located in the second row. We call this line segmen…
From:  johndcook.com/blog For a set of positive probabilities pi summing to 1, their entropy is defined as (For this post, log will mean log base 2, not natural log.) This post looks at a couple questions about computing entropy. First, are there any…
False coin Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16418   Accepted: 4583 Description The "Gold Bar"bank received information from reliable sources that in their last group of N coins exactly one coin is false and differs in…
这道题只是银牌组的第一题而我就写了 3K 的代码.唉. Description - 问题描述 FJ's N cows (2 <= N <= 100,000) are standing at various positionsalong a long one-dimensional fence. The ith cow is standing atposition x_i (an integer in the range 0...1,000,000,000) and is eithera pla…
题目链接: 题目 Ladies' Choice Time Limit: 6000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu 问题描述 Teenagers from the local high school have asked you to help them with the organization of next year's Prom. The idea is to find a suitable date for eve…