K - Rounders
Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87643#problem/K

Description

After the shameful loss in the match against Jesus Quintana, The Dude, Donny and Walter decided to turn to poker and become rounders. First of all, they decided to learn to deal with cards.
Walter gave Donny a simple task—he should split a deck of 52 cards into four piles in such a way that cards in each pile would be sorted in the order of ascending value. Two should be the topmost card, three should be the next card and so on. Ace should lie in the bottom. Walter wanted all decks to be comprised of the cards of the same suit but he forgot to mention it. As a result, the suits in piles were shuffled.
The Dude decided to save the day. But after five White Russians he poured into himself yesterday he isn't in a good condition for thinking. In fact, he is able to perform only the following actions:

  • take a few cards of one suit from the top of a deck and create a new deck of them;
  • take a few cards of one suit from the top of a deck and put them onto a card which value is greater by one than the value of the bottommost of the taken cards.

The Dude doesn't change the order of cards while moving them.

Help The Dude to complete Walter's task before Walter get insane and shoot both his best friends with Uzi.
 

Input

The input consists of four lines describing the piles of cards. Each line contains the description of 13 cards in a pile in order from top to bottom (that is, in the order of ascending values). Each card is denoted by its value and its suit. The value is one of the following: 2, 3, …, 9, T (ten), J (jack), Q (queen), K (king), A (ace), the suit can be: S (spades), C (clubs), D (diamonds) or H (hearts). All cards in the input are different.

Output

Output the minimal number of operations The Dude should perform in order to obtain four piles consisting of cards with the same suit.

Sample Input

2C 3C 4C 5C 6C 7C 8C 9C TC JC QC KC AC
2S 3S 4S 5S 6S 7S 8D 9D TD JD QD KD AD
2D 3D 4D 5D 6D 7D 8S 9S TS JS QS KS AS
2H 3H 4H 5H 6H 7H 8H 9H TH JH QH KH AH

Sample Output

3

HINT

题意

其实就是蜘蛛纸牌啦

一开始给你4个正确序列的纸牌

然后每次你就只能从上面拿下来一堆

然后问你最少几次操作可以得到上面的序列

题解

我们对于每一行判断就好了,如果这一行有两个区别的话,那就加3啦,如果有3个区别,就加4,如果有4个区别,那就有两种,特判一下就好了

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 5000
#define mod 10007
#define eps 1e-9
int Num;
//const int inf=0x7fffffff; //нчоч╢С
const int inf=0x3f3f3f3f;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//**************************************************************************************
int s[][];
int main()
{
//freopen("test.txt","r",stdin);
for(int i=;i<;i++)
{
for(int j=;j<;j++)
{
string ss;
cin>>ss;
if(ss[]=='C')
s[i][j]=;
else if(ss[]=='S')
s[i][j]=;
else if(ss[]=='D')
s[i][j]=;
else
s[i][j]=;
}
}
int ans=;
for(int i=;i<;i++)
{
int tot=;
for(int j=;j<;j++)
{
if(s[j][i]!=s[j][i+])
tot++;
}
if(tot==)
{
int flag=;
for(int j=;j<;j++)
{
for(int jj=;jj<;jj++)
{
if(s[j][i]==s[jj][i+]&&s[jj][i]==s[j][i+])
flag=;
}
}
if(flag)
ans++;
}
if(tot>)
ans+=tot+;
}
cout<<ans<<endl;
}

URAL 1784 K - Rounders 找规律的更多相关文章

  1. URAL 2070 Interesting Numbers (找规律)

    题意:在[L, R]之间求:x是个素数,因子个数是素数,同时满足两个条件,或者同时不满足两个条件的数的个数. 析:很明显所有的素数,因数都是2,是素数,所以我们只要算不是素数但因子是素数的数目就好,然 ...

  2. URAL 2065 Different Sums (找规律)

    题意:构造一个数列,使得它们的区间和的种类最少,其中数列中不同的数的数目不少于k. 析:我们考虑0这个特殊的数字,然后0越多,那么总和种类最少,再就是正负交替,那么增加0的数量. 代码如下: #pra ...

  3. URAL 1780 G - Gray Code 找规律

    G - Gray CodeTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view ...

  4. POJ2402 Palindrome Numbers第K个回文数——找规律

    问题 给一个数k,给出第k个回文数  链接 题解 打表找规律,详见https://www.cnblogs.com/lfri/p/10459982.html,差别仅在于这里从1数起. AC代码 #inc ...

  5. Nowcoder 练习赛 17 C 操作数 ( k次前缀和、矩阵快速幂打表找规律、组合数 )

    题目链接 题意 :  给定长度为n的数组a,定义一次操作为: 1. 算出长度为n的数组s,使得si= (a[1] + a[2] + ... + a[i]) mod 1,000,000,007: 2. ...

  6. Ural 2045. Richness of words 打表找规律

    2045. Richness of words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2045 Description For ...

  7. Ural 2037. Richness of binary words 打表找规律 构造

    2037. Richness of binary words 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=2037 Descripti ...

  8. hdu 1030 Delta-wave(数学题+找规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1030 Delta-wave Time Limit: 2000/1000 MS (Java/Others ...

  9. hdu 3951 - Coin Game(找规律)

    这道题是有规律的博弈题目,,, 所以我们只需要找出规律来就ok了 牛人用sg函数暴力找规律,菜鸟手工模拟以求规律...[牢骚] if(m>=2) { if(n<=m) {first第一口就 ...

随机推荐

  1. Linux应用层直接操作GPIO

    Linux应用层直接操作GPIO 在一个老手的指导下,应用层可以直接操作GPIO,具体指设置GPIO的输入输出以及输出电平高或者低.这个大大地提高了灵活性,官方的文档有GPIO Sysfs Inter ...

  2. HDU 5734 Acperience

    Acperience Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  3. HDU 2056 Rectangles

    Rectangles Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  4. Android aidl 打入jar解决方法

    工程上右键 选择export 然后取消选择这个工程里的所有的文件 点开到gen文件夹下选择aidl生成的 java文件 选择生成的java文件和src目录导出jar包即可

  5. WebView(网络视图)的两种使用方式

    WebView(网络视图)能加载显示网页,可以将其视为一个浏览器.它使用了WebKit渲染引擎加载显示网页,实现WebView有以下两种不同的方法:第一种方法的步骤:1.在要Activity中实例化W ...

  6. 【管理工具】Git的安装与使用

    公司与公司合并,需要学习一下git的使用.从网上找了一篇资料,完全满足需求,先赞一个. http://www.cnblogs.com/Bonker/p/3441781.html 下面记录一下自己的安装 ...

  7. Eclipse编辑java文件报Unhandled event loop exception错误的解决办法

    原因:电脑中安装了杀毒软件,卸掉或者关掉就可以了.我的是直接退出,错误就不产生了.

  8. [学习笔记] Web设计过程中该做和不该做的

    原文网址: http://www.javascriptstyle.com/the-dos-and-donts-of-web-design -该做的: QR代码QR代码即快速响应代码,这是矩阵条形码的一 ...

  9. Spark系列(十)TaskSchedule工作原理

    工作原理图 源码分析: 1.) 25              launchedTask = true 26            } 27          } catch { 28         ...

  10. 【SPOJ】Transposing is even more fun!

    题意: 给出a.b 表示按先行后列的方式储存矩阵 现在要将其转置 可以交换两个点的位置 求最小操作次数 题解: 储存可以将其视为拉成一条链 设a=5.b=2 则在链上坐标用2^***(a,b)表示为( ...