http://poj.org/problem?id=3087 设:s1={A1,A2,A3,...Ac} s2={Ac+1,Ac+2,Ac+3,....A2c} 则 合在一起成为 Ac+1,A1,Ac+2,A2......A2c,Ac 经过一次转换之后变成 s1={Ac+1,A1,Ac+2.....} s2={...A2c,Ac} 对应之前,每个数的序号发生的变化是 +1,+2,+3....-c,-c+1,..... 把整个数链想成环,也相当于是: +1,+2,+3....+c,+c+1,...…
POJ 3087 Shuffle'm Up(洗牌) Time Limit: 1000MS    Memory Limit: 65536K Description - 题目描述 A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and…
POJ.3087 Shuffle'm Up (模拟) 题意分析 给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12. 将字符串s1和s2通过一定的变换变成s12,找到变换次数 变换规则如下: 假设s1=12345,s2=67890 变换后的序列 s=6172839405 如果s和s12完全相等那么输出变换次数 如果不完全相等,s的前半部分作为s1,后半部分作为s2,重复上述过程. 直接模拟,注意给出的顺序是从底到上的. 代码总览 #include <cstdio…
题目传送门 /* 题意:两块扑克牌按照顺序叠起来后,把下半部分给第一块,上半部给第二块,一直持续下去,直到叠成指定的样子 DFS:直接模拟搜索,用map记录该字符串是否被搜过.读懂题目是关键. */ /************************************************ Author :Running_Time Created Time :2015-8-3 13:57:55 File Name :POJ_3087.cpp ***********************…
Shuffle'm Up Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 3087 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by s…
题目:http://poj.org/problem?id=3087 题意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s1,最顶的c块牌归为s2,依此循环下去. 现在输入s1和s2的初始状态 以及 预想的最终状态s12 问s1 s2经过多少次洗牌之后,最终能达到状态s12,若永远不可能相同,则输出"-1". #include <iostream> #include<cstdio> #…
题目链接:http://poj.org/problem?id=3087 题目大意:已知两堆牌s1和s2的初始状态, 其牌数均为c,按给定规则能将他们相互交叉组合成一堆牌s12,再将s12的最底下的c块牌归为s1,最顶的c块牌归为s2,依此循环下去. 现在输入s1和s2的初始状态 以及 预想的最终状态s12.问s1 s2经过多少次洗牌之后,最终能达到状态s12,若永远不可能相同,则输出"-1". 解题思路:照着模拟就好了,只是判断是否永远不能达到状态s12需要用map,定义map<…
link:http://poj.org/problem?id=3087 题意:给你两串字串(必定偶数长),按照扑克牌那样的洗法(每次从S2堆底中拿第一张,再从S1堆底拿一张放在上面),洗好后的一堆可以把下面的一半作为S1,上面的一半作为S2,问能否洗出题目给出的最终字串. 思路:很好能够找到规律,就是先把两串合并,分别存a[i],a[i+n/2]到新串中,这个新串就是当前洗出的结果.因此进行DFS,由于给出的串长为偶数(?)所以必定能够洗回初始状态,所以出口就是初始串. /** @Date :…
Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10003   Accepted: 4631 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks o…
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each stack may contain chips of several…
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each stack may contain chips of several…
题目链接:Shuffle'm Up 除了英文题有点恶心.发现模拟 + bfs 就可以过的时候,就是水了. 一个bug 就是filp函数得到string s12失败了.恩.据大腿告知,string 并不指定字符串的初始化长度是0,也就是说我每个元素的赋值是没有意义的.或者.string 是引用型数据类型,所以名字是一个指针吧.然后str.resize()函数愉快的解决了这个问题. 还有就是对题意.字符串从左到右是从下到上.我是懵了一下的. 题意思路见代码吧. /* 题目很长.也没有看.百度到题意.…
http://poj.org/problem?id=1426 测试了一番,从1-200的所有值都有long long下的解,所以可以直接用long long 存储 从1出发,每次向10*s和10*s+1转移,只存储余数即可, 对于余数i,肯定只有第一个余数为i的最有用,只记录这个值即可 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=222…
Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7404   Accepted: 3421 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of…
Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each stack may contain chips of several…
Shuffle'm Up Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14471 Accepted: 6633 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of po…
题意:给定s1,s1两副扑克,顺序从下到上.依次将s2,s1的扑克一张一张混合.例如s1,ABC; s2,DEF. 则第一次混合后为DAEBFC. 然后令前半段为s1, 后半段为s2. 如果可以变换成所给出的字符串,输出变换次数即可:否则,输出-1. 这题数据太水了,我是这样判断无法变换成题目所给出的字符串的:将每一次变换后的字符串存进数组,每次变换后由于之前变换后的字符串相比较,如果有相同的,就说明会无限循环下去.这样一来,循环次数会增加很多,然而0ms过了... #include <iost…
140. Integer Sequences time limit per test: 0.25 sec. memory limit per test: 4096 KB A sequence A is called an integer sequence of length N if all its elements A1 A2 .. AN are non-negative integers less than 2 000 000 000. Consider two integer sequen…
直达–>POJ 3087 Shuffle'm Up 题意:一开始没怎么看明白,注意现是从S2里拿牌放在最底下,再放S1,这样交叉放(我一开始以为是S1和S2随意哪个先放,分别模拟取最小),然后在从中间截一半,下半部给组成新的S1,上半部组成新的S2.然后再交叉洗牌,重复,问达到给出的S12最小的洗牌次数. 思路:题意懂了直接模拟就行,无法到达的情况就是某一次洗牌出来的S12和之前出现过的S12重合了,也就是形成了循环,此时无法达到给出的S12的情况那就是不可能了.判重没想到什么特别巧妙的方法就用…
Random Java中的Random类生成的是伪随机数,使用的是48-bit的种子,然后调用一个linear congruential formula线性同余方程(Donald Knuth的编程艺术的3.2.1节) 如果两个Random实例使用相同的种子,并且调用同样的函数,那么生成的sequence是相同的 也可以调用Math.random()生成随机数 Random实例是线程安全的,但是并发使用Random实例会影响效率,可以考虑使用ThreadLocalRandom变量. Random实…
import random x=[str(random.randint(0, 5)) for i in range(10)] x_str=''.join(x) y=[str(random.randint(0, 5)) for i in range(100000000)] y_str=''.join(y) if x_str in y_str: print("共有多少:") print(y_str.count(x_str)) print('第一个出现位置') print(y_str.fin…
Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15249   Accepted: 6962 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks o…
Shuffle'm Up 直接写中文了 Descriptions: 给定两个长度为len的字符串s1和s2, 接着给出一个长度为len*2的字符串s12. 将字符串s1和s2通过一定的变换变成s12,找到变换次数 变换规则如下: 假设s1=12345,s2=67890 变换后的序列 s=6172839405 如果s和s12完全相等那么输出变换次数 如果不完全相等,s的前半部分作为s1,后半部分作为s2,重复上述过程. Input 第一行给出T(1≤T≤1000),代表有T组数据,每组数据首先给出…
Shuffle'm Up Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7364   Accepted: 3408 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of…
青蛙的约会 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 104278   Accepted: 20356 Description 两 只青蛙在网上相识了,它们聊得很开心,于是觉得很有必要见一面.它们很高兴地发现它们住在同一条纬度线上,于是它们约定各自朝西跳,直到碰面为止.可是它 们出发之前忘记了一件很重要的事情,既没有问清楚对方的特征,也没有约定见面的具体位置.不过青蛙们都是很乐观的,它们觉得只要一直朝着某个方向跳下去…
题意:(1)有两副颜色多样的扑克牌,(A~H)表示不同颜色,给你两副牌,S1,S2和一副你需要洗出的KEY,S12由S2最底部,S1底部...一直下去,直到洗成S12,就是图片展示的那样.(2)洗好的S12可以重新变成新的S1,S2,S1是从下取S12牌数的一半,S2的从上取S12牌数的一半,问:这样操作有限次,能不能洗出S3,可以的话,求出最少洗牌次数,不能的话输出-1. 思路:算一个水题吧,简单的模拟,就是按照洗牌,拆牌那样模拟就好了,为了确定这个KEY能不能洗出, 需要一个map<stri…
题目链接:http://poj.org/problem?id=3087 Description A common pastime for poker players at a poker table is to shuffle stacks of chips. Shuffling chips is performed by starting with two stacks of poker chips, S1 and S2, each stack containing C chips. Each…
题目链接:http://poj.org/problem?id=1050 思路分析: 该题目为经典的最大子矩阵和问题,属于线性dp问题:最大子矩阵为最大连续子段和的推广情况,最大连续子段和为一维问题,而最大子矩阵为二维问题, 可以考虑将二维问题转换为一维问题,即变为最大子段和问题即可求解: 先考虑暴力解法,暴力解法需要枚举子矩阵的左上角元素的坐标与子矩阵的右下角坐标即可枚举所有的子矩阵:对于每个子矩阵,考虑压缩子矩阵的每一列 元素,即求每一列的元素的和,这样子矩阵就转换为一维的情况,再使用最大子段…
一. 题目 Maya Calendar Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 74085   Accepted: 22819 Description During his last sabbatical, professor M. A. Ya made a surprising discovery about the old Maya calendar. From an old knotted message,…
The Embarrassed Cryptographer Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11978   Accepted: 3194 Description The young and very promising cryptographer Odd Even has implemented the security module of a large system with thousands of…