【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

发牌的那个牌堆用一个deque,7个牌堆用vector来模拟。
然后按照题意模拟就好。
不难。

【代码】

/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
#include <bits/stdc++.h>
using namespace std; const int N = 8; deque <int> dl;
map <vector <int>, int > dic;
vector <int> pile[N];
bool bo[N];
int cur; int judge() {
vector <int> v;
v.clear();
for (auto i = dl.begin(); i != dl.end(); i++) {
v.push_back((*i));
} for (int i = 1; i <= 7; i++) {
v.push_back(0);
for (int x : pile[i]) {
v.push_back(x);
}
} if (dic.find(v) != dic.end()) return 1;
dic[v] = 1;
return 0;
} bool can() {
int len = pile[cur].size();
if (len<3) return false; int ju = pile[cur][0] + pile[cur][1] + pile[cur][len-1]; if (ju == 10 || ju == 20 || ju == 30) {
dl.push_back(pile[cur][0]);
dl.push_back(pile[cur][1]);
dl.push_back(pile[cur][len-1]); pile[cur].erase(pile[cur].begin());
pile[cur].erase(pile[cur].begin());
pile[cur].erase(pile[cur].end() - 1);
return true;
} ju = pile[cur][0] + pile[cur].back() + pile[cur][len - 2];
if (ju == 10 || ju == 20 || ju == 30) {
dl.push_back(pile[cur][0]);
dl.push_back(pile[cur][len - 2]);
dl.push_back(pile[cur][len - 1]); pile[cur].erase(pile[cur].begin());
pile[cur].erase(pile[cur].end() - 1);
pile[cur].erase(pile[cur].end() - 1);
return true;
} ju = pile[cur][len - 3] + pile[cur][len - 2] + pile[cur].back();
if (ju == 10 || ju == 20 || ju == 30) {
dl.push_back(pile[cur][len - 3]);
dl.push_back(pile[cur][len - 2]);
dl.push_back(pile[cur][len - 1]); pile[cur].erase(pile[cur].end() - 1);
pile[cur].erase(pile[cur].end() - 1);
pile[cur].erase(pile[cur].end() - 1);
return true;
} return false;
} int main() {
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
freopen("F:\\c++source\\rush_out.txt", "w", stdout);
#endif
ios::sync_with_stdio(0), cin.tie(0);
int x;
while (cin >> x && x) {
for (int i = 1; i <= 7; i++) bo[i] = true;
for (int i = 1; i <= 7; i++) pile[i].clear();
dic.clear();
while (!dl.empty()) dl.pop_back(); dl.push_back(x);
for (int i = 1; i <= 51; i++) {
cin >> x;
dl.push_back(x);
} judge();
int tot = 0; int ans;
cur = 1;
while (1) {
if (dl.empty()) { //lose
ans = -1;
break;
}
int cntalive = 0;
for (int i = 1; i <= 7; i++) cntalive += bo[i];
if (cntalive == 0) {//win
ans = 1;
break;
} //deal one card
if (cur > 7) cur = 1;
while (!bo[cur]) {
cur++;
if (cur > 7) cur = 1;
} pile[cur].push_back(dl.front());
dl.pop_front(); do {
} while (can()); if (pile[cur].empty()) bo[cur] = 0; tot++; int temp = judge();
if (temp == 1) {
ans = 0;//loop;
break;
}
cur++;
} if (ans == 0) {
cout << "Draw: ";
}
else if (ans == 1) {
cout << "Win : ";
}
else if (ans == -1) {
cout << "Loss: ";
}
cout << tot << endl;
}
return 0;
}

【习题 6-10 UVA - 246】10-20-30的更多相关文章

  1. “取出数据表中第10条到第20条记录”的sql语句+selecttop用法

    1.首先,select top用法: 参考问题 select top n * from和select * from的区别 select * from table -- 取所有数据,返回无序集合 sel ...

  2. “取出数据表中第10条到第20条记录”的sql语句+select top 使用方法

    1.首先.select top使用方法: 參考问题  select top n * from和select * from的差别 select * from table --  取全部数据.返回无序集合 ...

  3. c# Equal函数 and 运算符'==' (原发布 csdn 2017年10月15日 20:39:26)

    1.==.!=.<.>.<= 和>= 运算符为比较运算符(comparison operator).C#语言规范5.0中文版中比较运算符的描述如下: 2.通用类型系统 3.值类 ...

  4. 《java入门第一季》之HashSet小案例:获取10个1至20的随机数,要求随机数不能重复

    这是基于HashSet集合的唯一性. /*  * 编写一个程序,获取10个1至20的随机数,要求随机数不能重复.  *   * 分析:  * A:创建随机数对象  * B:创建一个HashSet集合 ...

  5. 题目:企业发放的奖金根据利润提成。 利润(I)低于或等于10万元时,奖金可提10%; 利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%; 20万到40万之间时,高于20万元的部分,可提成5%; 40万到60万之间时高于40万元的部分,可提成 3%; 60万到100万之间时,高于60万元的部分,可提成1.5%; 高于100万元时,超过

    题目:企业发放的奖金根据利润提成. 利润(I)低于或等于10万元时,奖金可提10%: 利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%: 20万到 ...

  6. 代码实现:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%; 利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%; 20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%; 60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元

    import java.util.Scanner; /* 企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%: 利润高于10万元,低于20万元时,低于10万元的部分按10%提成 ...

  7. UVA 246 - 10-20-30 (模拟+STL)

    UVA 246 - 10-20-30 题目链接 题意:给52张的扑克堆,先从左往右发7张牌,之后连续不断从左往右发7张牌,假设有牌堆形成了下面3种情况(按顺序推断): 1.头两张+尾一张和为10或20 ...

  8. 给定整数a1、a2、a3、...、an,判断是否可以从中选出若干个数,使得它们的和等于k(k任意给定,且满足-10^8 <= k <= 10^8)。

    给定整数a1.a2.a3.....an,判断是否可以从中选出若干个数,使得它们的和等于k(k任意给定,且满足-10^8 <= k <= 10^8). 分析:此题相对于本节"寻找满 ...

  9. gitlab 迁移、升级打怪之路:8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4 --> 10.2.5

    gitlab 迁移.升级打怪之路:8.8.5--> 8.10.8 --> 8.17.8 --> 9.5.9 --> 10.1.4 --> 10.2.5 gitlab 数据 ...

  10. 我的新计划 《2Dof Racing Simulator》2014/3/9 20:30:00

    最近好久都没来网站上了,也没心思和时间去弄VellLock和升级V&View了.一直在蕴量这做一件大玩意. 最近一直都很忙,忙着做数电课设,还有各种实验,可是我的心思不在这些东西上,当然除了数 ...

随机推荐

  1. Network Stack‎ : Disk Cache

    Disk Cache 目录 1 Overview 2 External Interface 3 Disk Structure 3.1 Cache Address 3.2 Index File Stru ...

  2. python 协程学习

    协程 协程,又称微线程,纤程.英文名Coroutine.一句话说明什么是线程:协程是一种用户态的轻量级线程. 协程拥有自己的寄存器上下文和栈.协程调度切换时,将寄存器上下文和栈保存到其他地方,在切回来 ...

  3. Django transaction 误用之后遇到的一个问题与解决方法

    今天在调试项目开发好的一个模块的时候,发现了一个很诡异的现象,最后追踪发现是因为在项目中事务处理有误所致.这个问题坑了我好一会,所以记录一下,以免再踩坑.下面开始详述. 我们都知道 Django 框架 ...

  4. PHP定时执行任务

    ignore_user_abort();//关掉浏览器,PHP脚本也可以继续执行. set_time_limit(0);// 通过set_time_limit(0)可以让程序无限制的执行下去 $int ...

  5. Python 爬取单个网页所需要加载的地址和CSS、JS文件地址

    Python 爬取单个网页所需要加载的URL地址和CSS.JS文件地址 通过学习Python爬虫,知道根据正式表达式匹配查找到所需要的内容(标题.图片.文章等等).而我从测试的角度去使用Python爬 ...

  6. java之 ------ 几种常见的简单设计模式

    前言: 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.用于解决特定环境下.反复出现的特定问题的解决方式.使用设计模式是为了可重用代码.让代 ...

  7. Activity中recreate方法的应用

    參考两篇文章:http://blog.csdn.net/watermusicyes/article/details/47392949     http://blog.csdn.net/droyon/a ...

  8. 使用 Facebook开源动画库 POP 实现真实衰减动画

    1. POP动画基于底层刷新原理.是基于CADisplayLink,1秒钟运行60秒,接近于游戏开发引擎 @interface ViewController () @property (nonatom ...

  9. .Net写的比较清晰的接口

    尼玛,隔行如隔山. .Net真操蛋. /// <summary> /// 加入群 /// </summary> /// <returns></returns& ...

  10. C#运算符小例子

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...