Trades FZU - 2281 (大数+贪心)】的更多相关文章

题目链接: J - Trades  FZU - 2281 题目大意: 开始有m个金币, 在接下来n天里, ACMeow可以花费ci金币去买一个物品, 也可以以ci的价格卖掉这个物品, 如果它有足够的金币, 每天可以买或卖很多次; 求它在第n天能获得的最大金币数.. 具体思路:相邻两个相比就可以了.保持每一天尽可能的拥有更多的金币.(题不难,主要是想存一java模板) AC代码: import java.util.*; import java.math.BigInteger; public cla…
This is a very easy problem. ACMeow loves GTX1920. Now he has m RMB, but no GTX1920s. In the next n days, the unit price of GTX1920 in the ith day is Ci RMB. In other words, in the ith day, he can buy one GTX1920 with Ci RMB, or sell one GTX1920 to g…
C Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 2102 Description You are given two positive integers A and B in Base C. For the equation: A=k*B+d We know there always existing many non-negativ…
题目链接:http://acm.fzu.edu.cn/problem.php?pid=2278 题目: 题意: 有n种卡牌,每种卡牌被抽到的概率为1/n,求收齐所有卡牌的天数的期望. 思路: 易推得公式为: 由于n的范围太大,直接求阶乘会爆,所以我们得用大数来求~ 代码实现如下: import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String arg…
Numbers Time Limit: 2 Seconds      Memory Limit: 65536 KB DreamGrid has a nonnegative integer n . He would like to divide n into m nonnegative integers a1,a2,...am and minimizes their bitwise or (i.e.a1+a2+...+am=n  and a1 OR a2 OR a3...OR am should…
题意:01给出一个数n,现在要将它分为m个数,这m个数相加起来必须等于n,并且要使得这m个数的或值最小. 思路分析: 一个简单的贪心,从高位到低位,判断当前位可否为 1 ,若可以,则将所有的数的这一位全部都变成 1 代码示例: import java.math.*; import java.util.*; public class study { public static void main(String[] args) { Scanner cin = new Scanner(System.i…
分析:http://blog.csdn.net/chenzhenyu123456/article/details/51308460 #include <cstdio> #include <cstring> #include <queue> #include <set> #include <map> #include <stack> #include <cstdlib> #include <algorithm>…
思路: 因为工人造完一个房子就死了,所以如果m<n则还需要n-m个工人. 最优的方案应该是耗时长的房子应该尽快建,而且最优的是越多的房子在建越好,也就是如果当前人数不到n,只派一个人去分裂. 解决方案是从还需要新的n-m个人入手,一个"旧人"先分裂的两个"新人",再去建造花费最小的两个房子,时间是max(t[i],t[j])+k; 类似哈夫曼树的合并. 利用优先队列解决. 外送一题:51nod1117 #include <cstdio> #incl…
参考自:https://blog.csdn.net/u013534123/article/details/78484494 题意: 给出两个数字n,m,把n分成m份,使得以下最小 思路: 或运算只有0|0=0,如果这一位有一个1,那么结果中这一位一定是1,所以我们要尽可能把1集中在几个位上(以二进制看结果) (二进制)主要的思想是把高位设置成1,这样可以分担大部分数值 用 i-1 位全部为1的二进制数t × m 与n进行判断 如果n大,说明n可以分成 pow(2,i)*m+x,x为不确定数字,这…
久违的月赛之二 Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice FZU 2139 Description 好久没举办月赛了,这次lqw又给大家出了5道题,因为hsy学长宣传的很到位,吸引了n个DDMM们来做,另一位kk学长说,全做对的要给金奖,做对4题要给银奖,做对3题要给铜奖.统计数据的时候,发现每题分别在n个人中有n1.n2.n3.n4.n5…