随笔分类 -  模拟题

易错
摘要:先生成蛇型矩阵,然后再筛选出素数进行标记,最后bfs。这里要注意题目要求的1-10000的之间的数路径,但是并不代表我们只要打印到这个范围的素数,因为很可能边沿的点需要走到外面的图形来完成对短路,外围的也不要打印太多,毕竟素数的个数越到外面是越稀疏的,所以打印到40000足矣。代码如下:#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#include <map>#define MAXN 40000using namespace std;i 阅读全文
posted @ 2012-07-16 22:20 沐阳 阅读(395) 评论(0) 推荐(0)
摘要:首先将7种方块拆成19种方块,然后在进行dfs组合,当然如果给定的N*M不是4的倍数的时候记得直接输出0。代码如下:#include <cstdlib>#include <cstring>#include <cstdio>using namespace std;int N, M, ans, END, G[35][35], many[20];int mp[20] = {1, 1, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 7, 7};char ss[50][6][6] = { { "####" 阅读全文
posted @ 2012-07-16 22:09 沐阳 阅读(5703) 评论(0) 推荐(0)
摘要:之前有听说如果在一个迷宫中一直沿着某一堵墙走的话,那么一定可以走出这个迷宫,这题讲的就是这个内容。这题的问法比较奇怪,问你沿着左边的墙,右边的墙走所花的时间和最少所花的时间。该题难点就在与如何让dfs的时候能够沿着墙走。其实是有规律的,那就是往左边走是顺时针方向dfs,往右走逆时针方向走dfs,每次要确定上一次来的方向,这样能够确定你第一次试探的方向是那个方向。例如:如果从最左边的墙进入的话,那么首先选择往上走,否则向前走,再否则向下走,最后还是没法走的话就向左走(往回走),走了之后就直接return,每次走了之后绝对不会再换方向搜索。这题竟然错在了手写的找最短路的队列上。代码如下:#in.. 阅读全文
posted @ 2012-07-12 23:53 沐阳 阅读(583) 评论(0) 推荐(0)
摘要:该题为一道纯模拟题,不需要任何算法。在选择棋子的时候定义好排序规则,将其一次排序出来。代码如下:#include <cstring>#include <cstdlib>#include <cstdio>#include <cctype>#include <algorithm>using namespace std;int pos = 0;int hash[255];struct Node{ char kind; int x, y; bool operator < (Node t) const { if (hash[kind] ! 阅读全文
posted @ 2012-06-30 11:16 沐阳 阅读(182) 评论(0) 推荐(0)
摘要:该题是个纯模拟题,只要仔细模拟就可以了,刚开始的时候自己按照自己的想法把行列关系进行了更改,结果弄得方向错乱。该证后AC。代码如下:#include <cstring>#include <cstdio>#include <cstdlib>#define MAXN 105using namespace std;int A, B, N, M, x[MAXN], y[MAXN], d[MAXN];int G[MAXN][MAXN];int dir[4][2] = {-1, 0, 0, 1, 1, 0, 0, -1};char box[MAXN]; // 接受信息s 阅读全文
posted @ 2012-06-29 20:32 沐阳 阅读(300) 评论(0) 推荐(0)
摘要:该题是一个模拟题,可能在理解题意上有所困难。第一个序列的意思为:a[i]表示第i个右括号的左边有多少个左括号第二个序列的意思为:b[i]表示第i个右括号跟与之匹配的左括号之间有多少左括号,包括与之匹配的左括号首先根据第一个序列将这个括号的序列进行恢复,然后再从右到左将第二个序列计算出来。代码如下:#include <cstring>#include <cstdlib>#include <cstdio>#include <algorithm>using namespace std;int s[100], N, seq[25], rec[25];// 阅读全文
posted @ 2012-06-29 17:16 沐阳 阅读(474) 评论(0) 推荐(0)
摘要:做法与1753相似。代码如下:#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#define START 0#define END 65535using namespace std;char G[6][6];int status, cpy, how[20], path[20], times;void pre(){ how[1] = 4383, how[2] =8751, how[3] = 17487, how[4] = 34959, how[5] = 阅读全文
posted @ 2012-06-28 12:06 沐阳 阅读(273) 评论(0) 推荐(0)
摘要:刚开始做这题时总是在想应该用何种的策略来进行翻装,最后还是没有想出来~~~ 这题过的代码的思路是用在考虑到每个点被翻装的次数只有0次或者是1次,所以对于16个点就只有2^16中请况了。再运用位运算将状态压缩到一个32位的整型当中,使用异或运算替代普通的运算。用dfs生成排列数。 代码如下:#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>#define START 0#define END 65535using namespace std;char G 阅读全文
posted @ 2012-06-28 11:12 沐阳 阅读(267) 评论(0) 推荐(0)
摘要:The Broken PedometerThe ProblemA marathon runner uses a pedometer with which he is having problems. In the pedometer the symbols are represented by seven segments (or LEDs):But the pedometer does not work properly (possibly the sweat affected the batteries) and only some of the LEDs are active. The 阅读全文
posted @ 2011-09-08 09:15 沐阳 阅读(929) 评论(0) 推荐(0)
摘要:模拟题。 代码如下:#include <cstdio>#include <cstring>#include <cstdlib>using namespace std;char q[2000];int main(){ while( gets( q ) ) { char * t, *p; int len = strlen( q ); t = q; while ( 1 ) { if( p = strchr( t, '?' ) ) { ... 阅读全文
posted @ 2011-08-29 15:07 沐阳 阅读(218) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3257 刚开始没有弄明白哪些十六进制数的意义,后来才恍然大悟,原来就是一个七行有无 '#' 二进制的表示,知道了这个后就比较简单了。 代码如下: 1 #include <cstring> 2 #include <cstdlib> 3 #include <cstdio> 4 using namespace std; 5 6 int num[85][10], base[10]; 7 8 int main() 9 {10 for( int i = 0; i < 阅读全文
posted @ 2011-08-29 13:38 沐阳 阅读(353) 评论(0) 推荐(0)
摘要:I Love You TooTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 865Accepted Submission(s): 531Problem DescriptionThis is atrue story. A man showed his love to a girl,but the girl didn't replied clearly ,just gave him a Morse Code:****-/*----/---- 阅读全文
posted @ 2011-08-29 12:49 沐阳 阅读(480) 评论(0) 推荐(0)
摘要:给定一个IP要求判断是否为正确IP。这里用sscanf进行处理较为方便。在数据末尾添加一个tail字符来判定是否还有缀余字符,利用到该函数的返回值。 #include <cstdio>#include <cstring>#include <cstdlib>using namespace std;bool r( int x ){ return x>= 0&& x<= 255? 1: 0;}int main(){ char ip[105]; while( gets( ip ) ) { int a, b, c, d, len= strl 阅读全文
posted @ 2011-08-16 22:34 沐阳 阅读(486) 评论(2) 推荐(0)
摘要:连连看Time Limit: 20000/10000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5613Accepted Submission(s): 1455Problem Description“连连看”相信很多人都玩过。没玩过也没关系,下面我给大家介绍一下游戏规则:在一个棋盘中,放了很多的棋子。如果某两个相同的棋子,可以通过一条线连起来(这条线不能经过其它棋子),而且线的转折次数不超过两次,那么这两个棋子就可以在棋盘上消去。不好意思,由于我以前没有玩过连连看,咨询了同学的意见 阅读全文
posted @ 2011-08-09 18:20 沐阳 阅读(1032) 评论(0) 推荐(0)
摘要:1567: 折纸Time Limit: 1 SecMemory Limit: 128 MBSubmit: 10Solved: 3[Submit][Status][Web Board]Description小熊vee很喜欢玩折纸,所以经常把她哥哥的作业本撕下来折纸,今天vee纸张的时候突然想到了一个问题,给你一张格子张纸(.... 就是小学时写作业用的小字本一样的格子)共有n行,m列,然后规定你有四种折的方法,top flip,bottom flip,left flip,right flip。top flip: 是将最上面的第一行翻折,并与第二行重叠,在第二行之上。(于是折之前的第二行将变为第一 阅读全文
posted @ 2011-08-03 18:44 沐阳 阅读(319) 评论(0) 推荐(0)
摘要:1560: The Least Palindromic NumberTime Limit: 1 SecMemory Limit: 128 MBSubmit: 111Solved: 15[Submit][Status][Web Board]Description Palindromic numbers are digital strings that read the same both forwards and backwards. For example, 121, 44 and 3 are Palindromic numbers, 175, 36 are not;For a given i 阅读全文
posted @ 2011-08-02 19:08 沐阳 阅读(481) 评论(0) 推荐(0)
摘要:1102: 月份牌Time Limit: 1 SecMemory Limit: 128 MBSubmit: 48Solved: 2[Submit][Status][Web Board]Description这里有一份2011年的月份牌可以参考 January February March Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 1 2 3 4 5 1 2 3 4 5 2 3 4 5 6 7 8 6 7 8 9 10 11 12 6 7 8 9 10 11 12 9 10 11 12 13 14 15 13 阅读全文
posted @ 2011-08-02 10:28 沐阳 阅读(383) 评论(0) 推荐(0)
摘要:1556: 网址Time Limit: 1 SecMemory Limit: 128 MBSubmit: 16Solved: 4[Submit][Status][Web Board]Description我们平时上网总是需要输入网址的,可是,这里有一堆的字符串,请判断这是不是一个网址。网址的规则如下:1、网址由协议、域名、端口、路径和文件构成,一个网址的实例:http://openoj.awaysoft.com:80/JudgeOnline/index.html2、协议,以协议名+://构成,如1中的http://,这里限定使用ftp和http两种协议,这部分可以省略。3、域名由字母、数字、下 阅读全文
posted @ 2011-08-01 22:24 沐阳 阅读(581) 评论(0) 推荐(0)
摘要:ACM Rank TableTime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 2979Accepted: 764DescriptionACM contests, like the one you are participating in, are hosted by the special software. That software, among other functions, preforms a job of accepting and evaluating teams' solutions (runs), an 阅读全文
posted @ 2011-07-22 18:20 沐阳 阅读(809) 评论(0) 推荐(0)
摘要:sortTime Limit : 3000/1000ms (Java/Other)Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 8Accepted Submission(s) : 3Font:Times New Roman|Verdana|GeorgiaFont Size:←→Problem DescriptionAs is known to all, long long ago sailormoon once was an association of fighters. Till now, sailormoon 阅读全文
posted @ 2011-05-16 22:52 沐阳 阅读(348) 评论(0) 推荐(0)