hdu 4023 2011上海赛区网络赛C 贪心+模拟
以为是贪心,结果不是,2333
贪心最后对自己绝对有利的情况
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
#define MOD 1000000007
const int INF=0x3f3f3f3f;
const double eps=1e-;
typedef long long ll;
#define cl(a) memset(a,0,sizeof(a))
#define ts printf("*****\n");
const int MAXN=;
int n,m,tt;
int a[MAXN];
int main()
{
int i,j,k;
#ifndef ONLINE_JUDGE
freopen("1.in","r",stdin);
#endif
scanf("%d",&tt);
int ca=;
while(tt--)
{
for(i=;i<=;i++) scanf("%d",a+i);
int st=,sum[],a1,a2; //st记录当前轮到谁了,sum[0]记录的是A的稳定步数,sum[1]记录的是B的稳定步数
cl(sum);
sum[]+=a[]*;
sum[]+=a[]*;
if(a[]!=) //只有一个的时候,谁先放谁的稳定步数会多一步
{
if(a[]%==)
{
sum[]++;
st^=;
}
}
a1=a[]+a[]; //对A有利
a2=a[]+a[]; //对B有利
if(a1>a2)
{
int w=a1-a2;
sum[]+=w/; //A只能获得其中一半的稳定步数,B什么都得不到
if(w%==)
{
if(st==)
{
sum[]++;
}
st^=;
}
}
else if(a2>a1)
{
int w=a2-a1;
sum[]+=w/; //B只能获得其中一半的稳定步数,A什么都得不到
if(w%==)
{
if(st==)
{
sum[]++;
}
st^=;
}
}
a1=a[]+a[]+a[]+a[];
st^=a1&; //仅仅改变步数
a1=a[]+a[]; //对B最不利,B要多走这个
a2=a[]+a[]; //对A最不利
if(a1>a2)
{
int w=a1-a2;
sum[]+=w/; //A只能获得其中一半的稳定步数,B什么都得不到
if(w%==)
{
if(st==)
{
sum[]++;
}
st^=;
}
}
else if(a2>a1)
{
int w=a2-a1;
sum[]+=w/; //B只能获得其中一半的稳定步数,A什么都得不到
if(w%==)
{
if(st==)
{
sum[]++;
}
st^=;
}
}
printf("Case #%d: ",ca++);
if(sum[]==sum[])
{
if(st)puts("Alice");
else puts("Bob");
}
else if(sum[]>sum[])
puts("Alice");
else puts("Bob");
}
}
hdu 4023 2011上海赛区网络赛C 贪心+模拟的更多相关文章
- hdu 4026 2011上海赛区网络赛F TSP ****
没看过TSP,先mark //4838039 2011-10-27 23:04:15 Accepted 4026 2343MS 31044K 3143 B C++ Geners //状态压缩DP的TS ...
- hdu 4025 2011上海赛区网络赛E 压缩 ***
直接T了,居然可以这么剪枝 题解链接:点我 #include<cstdio> #include<map> #include<cstring> #define ll ...
- hdu 4028 2011上海赛区网络赛H dp+map离散
一开始用搜索直接超时,看题解会的 #include<iostream> #include<cstdio> #include<map> #include<cst ...
- hdu 4027 2011上海赛区网络赛G 线段树 成段平方根 ***
不能直接使用成段增减的那种,因为一段和的平方根不等于平方根的和,直接记录是否为1,是1就不需要更新了 #include<cstdio> #include<iostream> # ...
- hdu 4038 2011成都赛区网络赛H 贪心 ***
贪心策略 1.使负数为偶数个,然后负数就不用管了 2.0变为1 3.1变为2 4.2变为3 5.若此时操作数剩1,则3+1,否则填个1+1,然后回到5
- hdu 4035 2011成都赛区网络赛E 概率dp ****
太吊了,反正我不会 /* HDU 4035 dp求期望的题. 题意: 有n个房间,由n-1条隧道连通起来,实际上就形成了一棵树, 从结点1出发,开始走,在每个结点i都有3种可能: 1.被杀死,回到结点 ...
- hdu 4044 2011北京赛区网络赛E 树形dp ****
专题训练 #include<stdio.h> #include<iostream> #include<string.h> #include<algorithm ...
- hdu 4050 2011北京赛区网络赛K 概率dp ***
题目:给出1-n连续的方格,从0开始,每一个格子有4个状态,左右脚交替,向右跳,而且每一步的步长必须在给定的区间之内.当跳出n个格子或者没有格子可以跳的时候就结束了,求出游戏的期望步数 0:表示不能到 ...
- hdu 4049 2011北京赛区网络赛J 状压dp ***
cl少用在for循环里 #include<cstdio> #include<iostream> #include<algorithm> #include<cs ...
随机推荐
- 同级兄弟元素之间的CSS控制
为了实现这个导航效果:选中菜单中某一项,隐藏掉自身的左边背景线条,同时让他的下一个兄弟元素也隐藏掉线条. 有一种选择器就叫兄弟元素选择器,分为临近兄弟和普通兄弟. 临近兄弟:用 + 表示,只匹配该元素 ...
- POJ 3322(广搜)
---恢复内容开始--- http://poj.org/problem?id=3322 题意:http://jandan.net/2008/01/24/bloxorz.html就是这个鬼游戏 我也是郁 ...
- js日期、月份:日期加一天等
// 日期,在原有日期基础上,增加days天数,默认增加1天 function addDate(date, days) { if (days == undefined || days == '') { ...
- Unity3D 给模型偏移纹理
给模型偏移纹理 using UnityEngine; using System.Collections; [RequireComponent(typeof(Renderer))] public cla ...
- MySQL数据故障时备份与恢复
1.ib_logfile0和ib_logfile1是mysql用来存储操作执行的日志文件,用于事务暂存和回滚.当复制ibdata1数据文件到新的mysql中时,如果没有拷贝这两个日志文件,则会出现启动 ...
- ACM/ICPC 之 Floyd练习六道(ZOJ2027-POJ2253-POJ2472-POJ1125-POJ1603-POJ2607)
以Floyd解法为主的练习题六道 ZOJ2027-Travelling Fee //可免去一条线路中直接连接两城市的最大旅行费用,求最小总旅行费用 //Time:0Ms Memory:604K #in ...
- Java for LeetCode 218 The Skyline Problem【HARD】
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- 【leetcode】Binary Tree Preorder Traversal (middle)★
Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tr ...
- LightOJ1336 Sigma Function(约数和为偶数的个数)
Sigma Function Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Submit ...
- css3属性flex弹性布局设置三列(四列)分布样式
参考:阮一峰的网络日志 <!doctype html> <html lang="en"> <head> <meta charset=&qu ...