Codeforces626B - Cards【模拟】】的更多相关文章

题意: 两张相同可以合并成相同: 两张不同可以产生另外一个不同: 求最终的可能颜色: 思路: 模拟啊. 总共也就那么几种情况,具体看挫code--. #include<iostream> #include<cstdio> #include<map> #include<set> #include<string> #include<queue> #include<math.h> #include<string.h>…
Soldier and Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Two bored soldiers are playing card war. Their card deck consists of exactly n cards, numbered from 1 to n, all values are…
B. Cards time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Catherine has a deck of n cards, each of which is either red, green, or blue. As long as there are at least two cards left, she can…
题目链接:http://codeforces.com/problemset/problem/546/C 题解: 用两个队列模拟过程就可以了. 特殊的地方是:1.如果等大,那么两张牌都丢弃 : 2.如果操作了很多次仍不能分出胜负,则认为平手.(至于多少次,我也不知道,只能写大一点碰运气,但要防止超时) 代码如下: #include<iostream>//C - Soldier and Cards #include<cstdio> #include<cstring> #in…
两个人玩牌,首先两个人都拿出自己手牌的最上面的进行拼点,两张拼点牌将都给拼点赢得人,这两张牌放入手牌的顺序是:先放对方的牌再放自己的.若最后有一个人没有手牌了,那么他就输了,求输出拼点的次数和赢得人的编号,如果一直无法结束比赛,则输出-1. 用队列模拟即可. #include <bits/stdc++.h> using namespace std; #define int long long #define ll long long #define reset(x) memset(x,0,si…
http://www.ifrog.cc/acm/problem/1036?contest=1005&no=0 分类,考虑Q神出的是第一张或者是第二张,然后对手出那些牌来应付. Q神出第一张和第二张的情况是分开的,应该取两者的最大值.(因为要取最优情况) 而Q神出第一张的时候,对手出任意一张,是取min,保证对手出牌最优 注意这里花色是没用的. #include <cstdio> #include <cstdlib> #include <cstring> #inc…
A. Bear and Five Cards time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a posit…
题目传送门 /* 题意:两堆牌,每次拿出上面的牌做比较,大的一方收走两张牌,直到一方没有牌 queue容器:模拟上述过程,当次数达到最大值时判断为-1 */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <string> #include <stack> #include <cmath> #inc…
题目链接:http://acm.swjtu.edu.cn/JudgeOnline/showproblem?problem_id=2213 思路分析:该问题与约瑟夫问题相似:每次将前n张牌放到队列的最后,可以将整个队列看做一个环,每次向前移动n步,则下一张牌的号码即被编号为n, 并在该环中除去该牌,在继续前行n+1步,如此循环,直到最后一张牌被编号. 代码如下: #include <iostream> using namespace std; ; int del[MAX_N]; int num[…
Collection工具类为操作List集合提供了几个有用的方法: reverse().shuffle().sort().swap().rotate(). 小例子: 使用shuffle(),方法模拟洗牌操作,并输出. import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.ListIterator; public class ShuffleCards {…
Fighting the Landlords Fighting the Landlords Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)Total Submission(s): 175    Accepted Submission(s): 61 Problem Description Fighting the Landlords is a card game which…
在内存中模拟出一副牌,然后模拟洗牌,发牌等动作. 流程是这样的:构建一副牌保存到一个数组中—洗牌—创建玩家—向玩家发牌–输出每个玩家的牌. #include <stdio.h> #include <stdlib.h> #include <time.h> //定义扑克的花色 enum Suit{ heart, spade, diamond, club, joker1, joker2 }; //一副牌的数量 #define CARD_COUNT 54 //定义扑克 type…
Cards 题意: 给你n个牌,n是偶数,要你把这些牌分给n/2个人,并且让每个人的牌加起来相等. 题解: 这题我做的时候,最先想到的是模拟,之后码了一会,发现有些麻烦,就想别的方法.之后发现只要把它给的数排序就好了,排完序后输出原来的位置就好,因为每2个都能配对所以最小肯定配最大,第二小配第二大-- 之后就可以a了 代码: #include <bits/stdc++.h> using namespace std; const int INF=0x3f3f3f3f; typedef long…
直接用STL里的queue模拟即可. #include <cstdio> #include <queue> using namespace std; ; int discarded[maxn], cnt; int main() { int n; && n) { cnt = ; queue<int> Q; ; i <= n; i++) Q.push(i); ) { discarded[cnt++] = Q.front(); Q.pop(); int…
题意:给出 n张牌,从上往下编号依次为1到n,当牌的数目至少还剩下2张时,把第一张牌扔掉,然后把新的一张牌放在牌堆的最底部,问最后剩下的那一张牌是哪一张牌. 模拟队列的操作------- #include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<vector> #include<queue> using namespace st…
HDU 4876 ZCC loves cards 题目链接 题意:给定一些卡片,每一个卡片上有数字,如今选k个卡片,绕成一个环,每次能够再这个环上连续选1 - k张卡片,得到他们的异或和的数,给定一个L,问能组成[L,R]全部数字的情况下,R的最大值是多少 思路:暴力C(20, 6),然后对于每一个序列去全排后模拟计算值, 只是之前要有个剪枝.全排前.先把k个数随机取数(即不用连续),然后假设这样还满足不了,那么连续的情况肯定也满足不了.直接结束.不进入全排.这样一来因为满足不了的情况实际上是占…
A poker deck contains 52 cards - each card has a suit which is one of clubs, diamonds, hearts, or spades (denoted C, D, H, S in the input data). Each card also has a value which is one of 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, king, ace (denoted 2,…
"Accordian" Patience You are to simulate the playing of games of ``Accordian'' patience, the rules for which are as follows: Deal cards one by one in a row from left to right, not overlapping. Whenever the card matches its immediate neighbour on…
题目: Problem B: Throwing cards away I Given is an ordered deck of n cards numbered 1 to n with card 1 at the top and card n at the bottom. The following operation is performed as long as there are at least two cards in the deck: Throw away the top car…
题目意思:有N张牌,标号为1~N,且牌以叠好,从上到小就是标号1-N的牌,只要牌堆数量大于等于2的时候,就采取如下操作:将最上面的牌扔掉(即离开牌堆).刚才那张牌离开后,再将新的最上面的牌放置于牌堆最后一张. 要求输出:依次输出被扔掉的牌,按扔掉的顺序输出.最后要输出最后留下的一张牌. 思路:用一个队列来模拟,被扔掉的牌相当于取出后进行pop操作,把最上面的牌放置最后相同于取出后进行pop操作和push操作,直至队列的size小于等于1 注意点:因为题目对格式的要求,所以第一张被扔掉的牌格式处理…
ZCC loves cards Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 260    Accepted Submission(s): 7 Problem Description ZCC loves playing cards. He has n magical cards and each has a number on it.…
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,0 ms) //UVa10935 - Throwing cards away I #include<iostream> #include<queue> int N; int main() { //freopen("in.txt", "r", stdin); while (scanf("%d", &N) !=…
Alice and Bob have a set of N cards labelled with numbers 1 ... N (so that no two cards have the same label) and a shuffle machine. We assume that N is an odd integer. The shuffle machine accepts the set of cards arranged in an arbitrary order and pe…
In a deck of cards, every card has a unique integer.  You can order the deck in any order you want. Initially, all the cards start face down (unrevealed) in one deck. Now, you do the following steps repeatedly, until all cards are revealed: Take the…
Problem UVA127-"Accordian" Patience Accept:3260  Submit:16060 Time Limit: 3000 mSec Problem Description You are to simulate the playing of games of “Accordian” patience, the rules for which are as follows: Deal cards one by one in a row from lef…
1.模拟斗地主 public class PlayCards { public static void main(String[] args) { String[] color = {"黑桃", "梅花", "方片", "红桃"}; String[] num = {"A", "2", "3", "4", "5", "6…
E. Cards Sorting time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this integer is between 1 and 10…
题目 https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2151 题意 麻将,有13张牌,问再加哪一张牌可以凑成一对,若干个三张和若干个三联. 思路 如刘书思路,明显,这是一道模拟题. 感想 1. 三倍ice cream! 代码 #include <algorithm> #include <cassert> #incl…
A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has started watching football games. He has learned that for some fouls the players receive yellow cards, and for some fouls they receive red cards. A player wh…
A. Bear and Five Cards 题目连接: http://www.codeforces.com/contest/680/problem/A Description A little bear Limak plays a game. He has five cards. There is one number written on each card. Each number is a positive integer. Limak can discard (throw out) s…