
暴力模拟
文章平均质量分 75
GooMaple
这个作者很懒,什么都没留下…
展开
-
UVa 146 - ID Codes
算是简单题吧,实质上就是求比给定字符串稍微大一点的字符串,只要从最后开始依次以最后一个元素为基准,向前与第一个比自身小的元素交换,然后把这个元素后边的元素按增序排列就可以了。代码如下:#include#include#include#include#include#includeusing namespace std;int c_cmp(const v原创 2012-07-31 09:38:12 · 1508 阅读 · 0 评论 -
ZOJ 3501 Roman Order
Roman OrderTime Limit: 2 Seconds Memory Limit: 65536 KBRoman numerals are based on seven symbols: I = 1, V = 5, X = 10, L = 50, C = 100, D = 500 and M = 1000.Symbols are iterated to pro原创 2012-08-01 14:04:37 · 991 阅读 · 0 评论 -
UVa 10132 - File Fragmentation
好久不交题了,而且发现最近状态恶劣的不行,AC率恶心到不行 ~这个题代码有点长,但实际思路很简单,qsort 拍一下序,然后,将最长的字符串与最短的字符串搭配,因为一个字符串最多分成两个不同的最长的字符串,所以最长与最短子字符串搭配最多8种情况,枚举出来,其中有一个就是所求的答案。代码如下:#include #include #include #include usin原创 2012-08-01 13:57:02 · 688 阅读 · 0 评论 -
UVa 10194 - Football
就是一个模拟题,稍有麻烦,基本还算是简单,但需注意的是题目有点问题,在第6条按字典序排序的时候是不分大小写的,在这里被坑了两次 ~~~代码如下:#include#include#include#includechar tourname[1000+2],game[1000][100];typedef struct Team{ int b,c,d,e,f原创 2012-07-30 16:37:11 · 533 阅读 · 0 评论 -
UVa 10033 - Interpreter
模拟题,关键是题意不太好理解,尤其是8,9两条命令不太好理解。8da: 表示将地址为“寄存器a的值”的内存单元的值拷贝到寄存器d.9sa:表示将寄存器s的值拷贝到地址为“寄存器d的值”的内存单元.代码如下:#include#include#include#include#includeusing namespace std;int reg[10];char inter原创 2013-01-30 19:44:13 · 861 阅读 · 0 评论 -
UVALive 4639 - Separate Points
Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit Status Practice UVALive 4639DescriptionNumbers of black and white points are placed on a plane. Let原创 2012-08-16 21:04:23 · 773 阅读 · 0 评论 -
HDU 3650 Hot Expo
Hot ExpoTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 886 Accepted Submission(s): 423Problem DescriptionSunny wants to go t原创 2012-08-06 19:36:38 · 773 阅读 · 0 评论 -
UVa 10245 - The Closest Pair Problem
看着比较简单,但10000的数据量让我TL了两次,需要进一步优化一下,剪一下枝后,AC了,rank还58,惊喜 ~~代码如下:#include#include#include#include#includeusing namespace std;struct point{ double x, y;} po[10000 + 2];int cmp(cons原创 2012-08-02 10:58:02 · 806 阅读 · 0 评论 -
UVa 270 - Lining Up
先依据横坐标和纵坐标的大小排一下序,然后以两个点为基准,判断一下其他点是否在以这两点为端点的线上,按照点的大小顺序依次扫过所有两个点为基准的线,注意判断点是否在线上时只判断比其小的点(即:朝一个方向判断,扫过的点便不再判断)~代码如下:#include#include#include#include#includeusing namespace std;stru原创 2012-08-02 10:56:14 · 880 阅读 · 0 评论 -
URAL 1102 Strange Dialog
一个元素一个元素往后判断,注意inputon和inputone等特殊情况的判断。用逆序判断会更加简单 。代码如下:#include#include#include#include#includeusing namespace std;char a[10000002];int solve(){ int len = strlen(a), flag = 0原创 2012-08-02 10:54:36 · 669 阅读 · 0 评论 -
UVa 10167 - Birthday Cake
暴力,最多一百个点,将所有点带入方程,使得大于零与小于零的个数相同(直线两边点的个数相同)。刚开始只判断了一边==num ,WA了好几边,换成两边都==num后,AC了 ~~代码如下:#include#include#include#includevoid makeit(int *a, int *b, int num){ int i, j; for(i原创 2012-08-01 13:56:25 · 553 阅读 · 0 评论 -
UVa 10098 - Generating Fast
简单题,和146 - ID Codes有几分相似,在此基础上做就可以了 ~代码如下:#include#include#include#include#include#includeusing namespace std;int c_cmp(const void *a,const void *b){ return *(char *)a-*(char原创 2012-07-31 09:50:57 · 520 阅读 · 0 评论 -
UVa 10196 - Check The Check
模拟题,代码稍长,一定仔细。代码如下:#include#include#include#include#includeusing namespace std;char Map[8][9];int Hstep_x[8] = {2, 2, -2, -2, 1, 1, -1, -1};int Hstep_y[8] = {1, -1, 1, -1, 2, -2, 2, -2};原创 2013-01-30 21:32:20 · 674 阅读 · 0 评论 -
HDU 3699 A hard Aoshu Problem
A hard Aoshu ProblemTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 62768/32768 K (Java/Others)Total Submission(s): 345 Accepted Submission(s): 173Problem DescriptionMath Ol原创 2012-08-12 09:44:53 · 1770 阅读 · 0 评论 -
ZOJ 1354 Extended Lights Out
Extended Lights OutTime Limit: 2 Seconds Memory Limit: 65536 KBIn an extended version of the game Lights Out , is a puzzle with 5 rows of 6 buttons each (the actual puzzle has 5 rows of 5原创 2012-08-01 14:19:40 · 1221 阅读 · 0 评论 -
POJ 3668 Game of Lines
比赛时的一个题,当时没有过,今天一检查竟然是qsort写错了一个数字~~~我那个悔死了,就差那么一点,实际其实就是一个简单的暴力。代码如下:#include #include#include#include#includeusing namespace std;int d_cmp(const void *_a,const void *_b){ double *a=原创 2012-07-30 16:48:38 · 1365 阅读 · 0 评论 -
HDU 1218 - Blurred Vision
简单模拟,题意有点难懂,实际就是给你一个 r*c 的矩阵,让你转化为一个(r-1)*(c-1)的矩阵,新矩阵中每个点的值为以其左上角为起点的四节点小矩阵之和的平均值。代码如下:#include #include int main(){ int r, c; char image[10][10], str[10]; while(scanf("%s", str)原创 2013-02-07 18:11:17 · 1054 阅读 · 0 评论