hdu 2662 Coin】的更多相关文章

Coin Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1020    Accepted Submission(s): 507 Problem Description Moon has many coins, but only contains two value types which is 5 cents and 7 cents,…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2069 Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent. We want to make changes with these coins for a given amount of money.For example, if we have 11…
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 10924 Accepted Submission(s): 3669 Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent…
Coin Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 888    Accepted Submission(s): 547 Problem Description After hh has learned how to play Nim game, he begins to try another coin game whi…
Coin Change Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 16592 Accepted Submission(s): 5656 Problem Description Suppose there are 5 types of coins: 50-cent, 25-cent, 10-cent, 5-cent, and 1-cent.…
题意:给你5种银币,50 25 10 5 1,问你可以拼成x的所有可能情况个数,注意总个数不超过100个 组合数问题,一看就是完全背包问题,关键就是总数不超过100个.所有我们开二维dp[k][j],表示使用k个硬币组成j的价值所有个数 接着就是直接使用完全背包,而且枚举硬币个数就只需要一次枚举1到100就好了 #include<set> #include<map> #include<queue> #include<stack> #include<cm…
这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就可以吃掉所有的.所以first必赢,} else {first无法一口吃掉所有的,所以second成了主动的了,如果first第一口吃掉k1个,那么明智的second只要吃掉k2个就可以了(n-k1-k2是偶数,也包括 0的),使得 剩下的数字是分成两个数字数目相等的堆,以后的工作便是first做什么,那么s…
思路: 当n<=k时,先手必胜: 当k=1时,n为奇数先手胜,否则后手胜: 当k>1时,先手操作之后必定形成链,后手操作后形成二条一样的链,之后,先手怎么操作,后手就怎么操作,则后手必胜. 代码如下: #include<stdio.h> int main(){ ,n,m; scanf("%d",&t); while(t--){ scanf("%d%d",&n,&m); printf(&&(n&)…
Coins Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 6279    Accepted Submission(s): 2561 Problem Description Whuacmers use coins.They have coins of value A1,A2,A3...An Silverland dollar. One d…
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1851 Accepted Submission(s): 1065 Problem Description After hh has learned how to play Nim game, he begins to try another coin game which seems much…
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 677 Accepted Submission(s): 321 Problem Description We know that Daizhenyang is chasing a girlfriend. As we all know, whenever you chase a beautiful…
2019 杭电多校 9 1006 题目链接:HDU 6685 比赛链接:2019 Multi-University Training Contest 9 Problem Description Rikka hates coins, and she used to never carry any coins with her. These days, Rikka is doing her summer internship abroad. Without mobile payment, Rikka…
链接 [http://acm.hdu.edu.cn/showproblem.php?pid=3537] 题意 题意:已知一排硬币中有n个硬币正面朝上,输入正面朝上的硬币的位置ai.两人轮流操作, 每次操作可以翻转1,2,或则3枚硬币,其中翻转的最右的硬币必须是正面朝上的,最后不能翻转的为负 分析 妮姆博奕变形&&找规律 代码 #include<iostream> #include<string.h> #include<map> using namespa…
Daizhenyang's Coin Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 183    Accepted Submission(s): 83 Problem Description We know that Daizhenyang is chasing a girlfriend. As we all know, wheneve…
#include<stdio.h> #include<algorithm> #include<string.h> using namespace std; ]; int main() { int n; int i,ans; while(scanf("%d",&n)!=EOF) { //ans=0; memset(a,,sizeof(a)); ;i<n;i++) scanf("%d",&a[i]); sort(…
先考虑两种简单的情况: 如果先手能一次把硬币拿完,即 k >= n ,那么先手胜 如果每次只能拿一个硬币, 即 k = 1 ,那么如果有奇数个硬币先手胜,如果有偶数个硬币后手胜. 剩下的情况就是先手一次拿不完,而且每次可以拿一个或者拿两个硬币. 剩下的硬币会变成一条链,如果后手能拿完最好,不能拿完的话就拿一个或两个硬币使这条链变成长度相等的两条. 这一定是能做到的, 因为如果这条链有奇数个硬币,那么拿走中间的那个: 如果有偶数个硬币,拿走中间的两个. 变成相等的两条链之后,先手在哪条链拿走多少个…
可以参考Thomas S. Ferguson的<Game Theory>,网上的博客大多也是根据这个翻译过来的,第五章讲了很多关于翻硬币的博弈. 这种博弈属于Mock Turtles,它的SG函数值是2x或2x+1. 把一个数写成二进制的形式,如果1的个数为奇数,把这种数叫做odious:否则就叫做evil.   话说这种名字好奇怪啊,= ̄ω ̄= 所以把每个正面朝上的硬币对应SG函数值异或起来就能得到答案. 还有这个题的坑就是:输入的数中可能有重复,所以去重后再计算! #include <…
详见:http://www.cnblogs.com/xin-hua/p/3255985.html 约束条件6 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #define in(x) scanf("%d",&x) using namespace std; ]; int ma…
题意:每次可以翻动一个.二个或三个硬币.(Mock Turtles游戏) 初始编号从0开始. 当N==1时,硬币为:正,先手必胜,所以sg[0]=1. 当N==2时,硬币为:反正,先手必赢,先手操作后可能为:反反或正反,方案数为2,所以sg[1]=2. 当N==3时,硬币为:反反正,先手必赢,先手操作后可能为:反反反.反正反.正反正.正正反,方案数为4,所以sg[2]=4. 位置x:0  1  2  3  4   5    6   7    8     9  10  11  12  13  14…
题意: 有一些1毛,2毛,5毛,1块的钢镚,还有一些价格不同的商品,现在要求你带一些钢镚,以保证这些商品中任选一件都能正好用这些钢镚付账,问最少带多少钢镚. 题解: 对于最优解,1毛的钢镚最多带1个,带两个就还不如带一个2毛的,同理2毛的最多带四个,5毛的最多带1个,一块的没有限制. 因此,预处理出1个1毛,4个2毛,1个5毛的所有子集,它们分别能组成哪些额度. 暴力枚举,并维护最少1块数量即可. #include<iostream> #include<set> #include&…
题目链接 思路:考虑第一个人取的方式: 1.每次能取的次数>= n, 一次取完 first win 2.每次能取1个,n是奇数 first win 3.一次取不完,这种情况下也分2种情况 1)second能一次取完, second win 2)second不能一次取完,则他取一次使得这个链至少有一个部分是能一次取完的 若2个部分都是一次取完的,second win 若1个部分是一次取完的,另一个部分不行,又分两种情况 #1first选择取可以取完的那一堆,那么状况又回到了second取一堆不可以…
题意: 给你n个硬币,你可以从中拿出来1.2.3个硬币,它们不一定要连续,你只需要保证拿出来的硬币中那个下标最大的硬币一定要是正面朝上,最后谁不能操作,谁就输了 题解: 翻硬币游戏 结论: 局面的SG 值为局面中每个正面朝上的棋子单一存在时的SG 值的异或和.即一个有k个硬币朝上,朝上硬币位置分布在的翻硬币游戏中,SG值是等于k个独立的开始时只有一个硬币朝上的翻硬币游戏的SG值异或和.比如THHTTH这个游戏中,2号.3号.6号位是朝上的,它等价于TH.TTH.TTTTTH三个游戏和,即sg[T…
HDU 1144 Piggy-Bank 题意:有这么个存钱罐,给你空的时候重量和满的时候的重量,再给你N中类型的硬币(给出N种硬币总数量和总重量,可多次使用),问你怎样恰好填满存钱罐,而让填入的硬币数量最少. 思路:完全背包,求最少填入硬币数量,要把dp数组全部填充为INF,求min,注意结果要恰好填满. dp[j]= min(dp[j],dp[j-w[i]]+v[i])(dp[j]代表当前步,所用硬币最小数目) /** Sample Input 3 10 110 2 1 1 30 50 10…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others)Total Submission(s): 5094    Accepted Submission(s): 2985 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his mi…
Piggy-Bank Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 1114 Appoint description:  System Crawler  (2015-09-06) Description Before ACM can do anything, a budget must be prepared and the neces…
题目链接: POJ:http://poj.org/problem?id=3835 HDU:http://acm.hdu.edu.cn/showproblem.php?pid=3268 Problem Description On the evening of 3 August 1492, Christopher Columbus departed from Palos de la Frontera with a few ships, starting a serious of voyages o…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/1000 K (Java/Others) Total Submission(s): 4972    Accepted Submission(s): 2908 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his m…
kiki's game Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 40000/10000 K (Java/Others)Total Submission(s): 10763    Accepted Submission(s): 6526 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his…
题目传送:http://acm.hdu.edu.cn/showproblem.php?pid=2147 Problem Description Recently kiki has nothing to do. While she is bored, an idea appears in his mind, she just playes the checkerboard game.The size of the chesserboard is n*m.First of all, a coin i…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=2069 题意 有面值1,5,10,25,50的硬币数枚,对于输入的面值n,输出可凑成面值n(且限制总硬笔数小于等于100枚)的方案数.特别的,n=0时方案数=1. 其中,输入n<=250. 思路 DP. 状态 ways[j][i] 表示面值等于j且硬币枚数等于i时的方案数. 初始化时,只需将ways[0][0]=1即可,其他为0: 外层先遍历硬币面值种类,这层遍历的具体顺序不重要,即保证有不重复累加同…