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. windows批处理中的%0 %1 %2 %3

    原来就是参数的顺序.....倒...我还查了老半天

  2. Ecshop ajax 局部刷新购物车功能

    1.比如我们category.dwt 里有 <a href='flow.php'><SPAN id='cart_count_all'>{insert name='cart_in ...

  3. POJ 1160 Post Office

    题意:有n个村庄,要在其中m个村庄里建邮局,每个村庄去邮局的代价为当前村庄到最近的一个有邮局村庄的路程,问总最小代价是多少. 解法:dp.dp[i][j]表示在前j个村庄建立i个邮局后的代价,则状态转 ...

  4. hdu 1175(广搜)

    题意:容易理解... 思路:我开始的思路不好实现,而且有漏洞,时间复杂度也高,后来在网上学了下别人的方法,真心感觉很牛B,不仅代码好实现,而且时间复杂度比较低,具体看代码实现吧!! 代码实现: #in ...

  5. vim简单使用教程

    vim的学习曲线相当的大(参看各种文本编辑器的学习曲线),所以,如果你一开始看到的是一大堆VIM的命令分类,你一定会对这个编辑器失去兴趣的.下面的文章翻译自<Learn Vim Progress ...

  6. linux-LINUX试题

    ylbtech-doc:linux-LINUX试题 LINUX试题 1.A,LINUX试题返回顶部 01.{Linux题目}在使用匿名登录ftp时,用户名为(  )? (选择1项) A) login ...

  7. 10、TV UI

     TV UI布局 1. 为大屏幕提供适当的布局源文件. 2. 确保UI在一定距离仍然可以看清. 3. 为高清电视提供高分辨率的图标和图像. 1. 把屏幕上的导航控制菜单放在屏幕的左边或者右边,并且将 ...

  8. SQL 语句记录

    1.创建一个table @"create table rockTB(myId integer primary key autoincrement not null, time varchar ...

  9. 软件测试技术(六)——白盒测试之控制流覆盖准则+Visual Studio 2013单元测试

    一.目标程序 单片机发送的A/D转换结果的整体格式为:[DLE][STX]Message[CHKSUM][DLE][ETX],其中[]括号中的字符为16进制的助记符,并非ASCII码.其中:[DLE] ...

  10. C#复习反射

    反射中常用方法: //获取对象类型 One one = new One(); Type t = one.GetType(); //动态加载 Assembly a = Assembly.LoadFile ...