hdu 3544 Alice's Game】的更多相关文章

#include<stdio.h> int main() { int t,n; __int64 sum1,sum2; int i,j,a,b; scanf("%d",&t); ;i<=t;i++) { scanf("%d",&n); sum1=sum2=; ;j<n;j++) { scanf("%d%d",&a,&b); &&b>) { a>>=; b>…
博弈论+二分! 后一人会尽量选前一人切小的一块切!! 代码如下: #include<iostream> #include<stdio.h> #define I1(x) scanf("%d",&x) #define I2(x,y) scanf("%d%d",&x,&y) int main(){ ,a,b; __int64 m1,m2; I1(t); while(t--){ I1(n); m1=m2=; ;i<=n;…
题目链接:hdu 4122 Alice's mooncake shop 题意: 有n个订单和可以在m小时内制作月饼 接下来是n个订单的信息:需要在mon月,d日,year年,h小时交付订单r个月饼 接下来一行t,s表示制作的月饼可以保质t天,每保质一天需要花费s的价值 接下来m行表示从第0小时开始在该时间制作月饼的花费的价值 求完成所有订单消耗的最小价值. 题解: 这题我还是看了很久才看懂题意,我们将读入的订单处理后,实质就是在一个时间轴上求每个订单时间点i的t区间,也就是i-t<j<=i这个…
切巧克力的游戏,想得还是不是太明白. 后者会尽量选前着切后其中小的一块来切,那么先手须尽量取中间来切. So?题解都是这么一句话,不知道是真懂了还是从别人那抄过来的. 后来找到一个官方题解,分析得比较认真,但我这智商还是没懂太多,QAQ 本题我抄袭自<Winning Ways for your Mathematical Plays> ,一本关于游戏论的科普类图书.这题是一个组合游戏,但是并不是一个对等的组合游戏,所以试图使用 SG 函数相关知识解答是会面临巨大的挑战的. 书中本题的做法描述得十…
Alice's mooncake shop Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4122 Description The Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu Festival is a popular harvest festival celebrated by Ch…
A - Alice's Print Service Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4791 Description Alice is providing print service, while the pricing doesn't seem to be reasonable, so people using her…
Alice and Bob Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=4111 Description Alice and Bob are very smart guys and they like to play all kinds of games in their spare time. The most amazing thing is that they…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5054 Problem Description Bob and Alice got separated in the Square, they agreed that if they get separated, they'll meet back at the coordinate point (x, y). Unfortunately they forgot to define the origi…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4791 解题报告:打印店提供打印纸张服务,需要收取费用,输入格式是s1 p1 s2 p2 s3 p3...表示打印区间s1到s2张纸的单价是p1,打印区间s2 到s3的单价是p2....最后是sn到无穷大的单价是pn,让你求打印k张纸的总费用最少是多少?有m次查询. 因为s1*p1 > s2 * p2 > s3*p3......,很显然,加入k所在的那个区间是第x个区间,那么最低费用要么是k * p…
Alice and Bob Time Limit : 10000/5000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 5   Accepted Submission(s) : 1 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Alice and Bob's game nev…
copy VS study 1.每堆部是1的时候,是3的倍数时输否则赢: 2.只有一堆2其他全是1的时候,1的堆数是3的倍数时输否则赢: 3.其他情况下,计算出总和+堆数-1,若为偶数,且1的堆数是偶数,则一定输: 4.不在上述情况下则赢. #include<stdio.h> int main() { ; int _case,i,n,x; int flag1,flag2,flag,sum; scanf("%d",&_case); while(_case--) { j…
题意: 一个无限大的棋盘,一开始在1,1,有三种移动方式,(x+1,y)(x,y+1) (x+k,y+k)最后走到nm不能走了的人算输.. 析:.我们看成一开始在(n,m),往1,1,走,所以自然可以从1,1,开始递推往出,那么打表程序就出来了.. 打出表以后我们观察到k等于1时稍有特殊,其他则与  (min(cx,cy)&1)^((n+m)&1)) 有关ps(其中cx=n/(k+1),cy=m/(k+1)) 那么就愉快的分类讨论外加试一试和表对照一下就好了.. 代码如下: #includ…
这里有2种方法: 方法一:求SG函数 sg[i][j]:i表示1的个数,j表示合并操作的步数. 这共有4种操作: 1.消除一个1: 2.减掉一个1: 3.合并2个1: 4.把1合并到另外不是1中. 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #incl…
Alice's Print Service Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1855    Accepted Submission(s): 454 Problem Description Alice is providing print service, while the pricing doesn't seem to…
组合游戏题: 组合游戏的规则: 1.必败态的所有后继都是必胜态: 2.必胜态最少有一个必败的后继: 这里的必胜态是f[1][0][0][0]; 其中f[a][b][c][d]表示有a个1,b个2,c个3,d个4是不是一个必胜态: 可以认为大于3的奇数等同于3,大于4的偶数等同于4. 然后递归求解: #include <iostream> using namespace std; ][][][]; ][][][]; int F(int a,int b,int c,int d) { if (!vi…
树形dp,这道题如果选G++的话,只输入都会超时.我是C++ 1900ms + 飘过的...但是输入优化后就快了很多了,1100ms左右.dfs按层次求最值就行了,差不多也算是博弈吧,到bob取的时候要选尽量大的分支(满足条件L和R之间的情况下),反之要alice选尽量小的分支.然后一遍dfs就可以了,时间复杂度为O(n). #include<algorithm> #include<iostream> #include<cstring> #include<fstr…
题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=4268 贪心思想,用set实现平衡树,但是set有唯一性,所以要用 multiset AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <cstdlib> #include <cmath> #include &…
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4122 题意:好难读懂,读懂了也好难描述,亲们就自己凑合看看题意把 题解:开始计算每个日期到2000/1/1日0点有多少个小时,然后求出每个小时的时候每个的最小单价(包括成本+储存费用) 使用单调队列,维护队列,使之到i 生产的最优 AC代码: #include <iostream> #include <cstdio> #include <cstring> #include &…
Alice and Bob Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2901    Accepted Submission(s): 941 Problem Description Alice and Bob's game never ends. Today, they introduce a new game. In this…
http://acm.hdu.edu.cn/showproblem.php?pid=6249 题意: 给出n个区间,求选k个区间的最大区间并. 思路: 可能存在左端点相同的多个区间,那么此时我们肯定选右端点最大的那个区间.现在将区间按左端点排序,d[i][j]表示在1-i坐标轴范围内选择j个区间的最大区间并. 状态转移方程如下: dp[i+][j] = max(dp[i][j],dp[i+][j]); //不选的话就和上一个一样 dp[i+num][j+] = max(dp[i][j]+num,…
Alice's mooncake shop Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2596    Accepted Submission(s): 619 Problem Description The Mid-Autumn Festival, also known as the Moon Festival or Zhongqiu…
Alice and Bob's Trip Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2643    Accepted Submission(s): 708 Problem Description Alice and Bob are going on a trip. Alice is a lazy girl who wants to…
B - Alice and Bob Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description Alice and Bob's game never ends. Today, they introduce a new game. In this game, both of them have N different rectangular cards respectively.…
题意:给定 n 堆石头,然后有两种操作,一种是把从任意一堆拿走一个,另一种是把一个石子放到另一堆上. 析:整体看,这个题真是不好做,dp[a][b] 表示有 a 堆1个石子,b个操作,操作是指把其他的不是1的堆全部合并起来并全部拿完所以要的操作, 要注意的是 ,一共有这几种情况. 1.a 为0,说明没有一堆的,全是另一种操作,这一种是看操作个数,如果是奇数,先手胜. 2.a 为 1,说明只有只有一堆 为1的, 这个是先手必胜,因为如果 b是偶数,那么就可以先合并,如果是 b 是奇数,就是直接拿掉…
题目链接 HDU 6249 题意 给定$m$个区间,在这些区间中选出不超过$k$个,求被覆盖的点的数量的最大值. 设$f[i][j]$表示选到第$i$个点并选了$j$个区间的时候能得到的最大答案. 处理到第$i$个点的时候观察所有覆盖$i+1$这个点的线段,找到延伸到最右端的这条线段. 假设该线段延伸到$r$,那么更新$f[r][j + 1]$. 最后枚举答案即可. #include <bits/stdc++.h> using namespace std; #define rep(i, a,…
点击打开链接 Alice's Print Service Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1084    Accepted Submission(s): 240 Problem Description Alice is providing print service, while the pricing doesn't…
题意:卡牌覆盖,每张卡牌有高(height)和宽(width).求alice的卡牌最多可以覆盖多少bob的卡牌 思路:贪心方法就是找h可以覆盖的条件下找w最大的去覆盖. #include<iostream> #include<stdio.h> #include<set> #include<algorithm> using namespace std; struct Node{ int h,w; int flag; }node[]; bool cmp(Node…
 题意: Alice和Bob有n个长方形,有长度和宽度,一个矩形能够覆盖还有一个矩形的条件的是,本身长度大于等于还有一个矩形,且宽度大于等于还有一个矩形.矩形不可旋转.问你Alice最多能覆盖Bob的几个矩形? 思路:贪心,先依照h将Alice和Bob的矩形排序,对于Alice的每一个矩形.假设Bob的矩形的h小于Alice的h,将Bob的w插入到集合中. 然后,在集合中找到不大于Alice矩形d的最大的Bob的d,那么这样做肯定是最优的. #include<cstdio> #includ…
题意: 一个月饼店做月饼,总营业时间m小时,只能在整点做月饼,可以做无限个,不过在不同的时间做月饼的话每个月饼的花费是不一样的,假设即为cost[i],再给n个订单,即为在某个时间要多少个月饼,时间从2000年1月1日0时开始计算,必须在每个订单的时间之前完成这么多月饼,月饼还有保质期T小时以及保存费用S每小时,现在问满足这n个点的最小成本是多少. 解法: 因为月饼有保质期T,所以第i个月饼只能在[Ti-T+1,Ti]时间内做好.如果时间j有订单,假设在时间i做月饼是最好的,那么这个订单每个月饼…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABJEAAAE6CAIAAAApz1RvAAAgAElEQVR4nO3d3css1b3g8fyTdbHJbD…