自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(58)
  • 资源 (1)
  • 问答 (1)
  • 收藏
  • 关注

原创 UVA 644 Immediate Decodability (寻找前缀)

分析:直接暴力求解,尝试每个是不是另外每个的前缀便可#include #include char sb[105][105];int judge = 0;int main(){ int t = 0; int tt = 1; while (gets(sb[t ++]) != NULL) { if (sb[t - 1][0] == '9')

2015-12-23 22:09:34 299

原创 UVA 10115 Automatic Editing (字符串的替换和查找)

分析:水题,熟悉字符串的find和replace函数便可轻易解决好久每一1A的题了,UVA的格式要求真是醉了,每次都得调试半天格式#include #include #include #include #include #include using namespace std;int main(){ string f[11],re[11];

2015-12-23 22:02:34 370

原创 UVA 10878 Decode the tape (二进制)

分析:这个题跪了,真没想到他是这样解码规律的,有7个位置,2的7次方=128,正好是ASCII码。(0100000=32正好是空格的ASCII码,而且正好符合输出的空格)所以这个题就很简单了,每行是一串二进制,o代表1;解码二进制,之后输出它所对应的字母便可#include #include int cun[]={0,0,64,32,16,8,0,4,2,1,0};i

2015-12-23 22:00:03 294

原创 UVA 409 Excuses(借口)

分析:字典集合存储,之后count函数使用;本题的理念是对的,但有个地方总是存在格式问题,WA数次,一跪再跪,醉了#include #include #include #include #include #include #include using namespace std;int main(){ string str; string cun

2015-12-23 21:48:58 263

原创 UVA 10361 Automatic Poetry

分析:水题,遍历寻找四个的位置便可#include #include #include .using namespace std;int main(){ int t; string s,ss,s1,s2,s3,s4; while (scanf("%d",&t)!=EOF) { getchar();

2015-12-23 21:45:06 272

原创 UVA 10010 Where's Waldorf? (DFS)

分析:英文题就是难懂,看了好久也没看明白,原来是一次只能朝一个方向深搜到底。此坑一解,本题就类似于油田问题了。#include#include#include#include#includeusing namespace std;int m,n;int pX;int pY;char pic[60][60];int dx[] = {-1,

2015-12-23 21:39:12 353

原创 UVA 699 下落的树叶 (p159, 二叉树的 DFS)

分析:这个题的输入是先序遍历,发现这点很重要。统计每个层次的树叶总数,可以把整个树看作在一个一维坐标系中。#include int a[81],left,right;//记载左右边界void dfs(int num,int pos){ int x,y; if (num!=-1) { if (pos<left) left=pos;

2015-12-23 20:47:41 581

原创 UVA 536 Tree Recovery (先加中建树)

分析:类似上一篇博客#include #include #include #include using namespace std;const int maxn=30;struct Node{ char data; struct Node *left,*right;};struct Node node[maxn];char xianxu[maxn],zho

2015-12-23 20:43:07 388

原创 UVA 548 树 ( 从中序和后续回复二叉树)

分析:由中序,后序转为先序。要清楚三种遍历方式,能用先序和中序转为后序,由后序和中序转为前序#include#include#include#includeusing namespace std;const int maxn=10005;int inOrder[maxn], postOrder[maxn], nIndex;struct Node{ in

2015-12-23 20:36:02 280

原创 UVA 657 The die is cast (DFS*2)

分析:双DFS,一个搜索*,一个搜索X;(遍历完每个地方后把他变为背景‘.’)题意就是判断X(连通算一个,四方向遍历)的个数,也就是筛子的点数。题意很简单,但程序写起来还是有难度的,WA数次。(本题类似于古代象形符号)#include #include #include #include #include #include using namespace std

2015-12-21 06:52:46 310

原创 UVA 755 487--3279

分析:这个题就有点难度了,设置一个常量数组必不可少,神器记录每个电话号码出现的次数即可。UVA的题的格式真是让人一醉再醉,一跪再跪,空行,一定要读懂题意,看明白空行所在的位置。。。WA数次,该死的空行#include #include #include #include #include #include #include using namespa

2015-12-21 06:44:38 490

原创 UVA 299 Train Swapping

分析:模拟冒泡排序的过程即可。#include int main(){ int carriage[55]; int T; scanf("%d",&T); while (T--) { int n,ans=0; scanf("%d",&n); for (int i=0;i<n;i++)

2015-12-21 06:39:20 309

原创 UVA-152 Tree's a Crowd

分析:水题,暴力搜一下每个数到所有数的最小距离即可(三维坐标)#include #include #include #include #include const int maxn=5010;using namespace std;int a[maxn],b[maxn],c[maxn],g[10];int dis(int i,int j){ return s

2015-12-21 06:37:24 308

原创 UVA-10420 List of Conquests

分析:神器的简单应用#include #include #include #include #include #include using namespace std;int main(){ char str[80],s[80]; int n; map m; scanf("%d",&n); while (n--)

2015-12-21 06:33:55 365

原创 UVA-340 Master-Mind Hints (猜数字)

分析:猜数字游戏,水题#include #include #include using namespace std; const int N = 1005; int a[N], b[N], c, d; int main() { int n, cas = 0; while (scanf ("%d", &n), n) {

2015-12-21 06:30:57 426

原创 UVA-10054 The Necklace

分析:欧拉回路问题,无向图,只要判断每个节点度数是否全为偶数即可。但本题还多了一个打印路径问题,DFS从最后的那个节点遍历便可。#include#include int n,lujing[60][60];void euler(int m)//打印路径(紫书上有详细的){ int i; for (i=1;i<=50;i++) if (lujing[m][i

2015-12-18 08:45:48 286

原创 公共汽车

题目描述: 一个城市的道路,南北向的路有n条,并由西向东从1标记到n,东西 向的路有m条,并从南向北从1标记到m,每一个交叉点代表一个路口, 有的路口有正在等车的乘客。一辆公共汽车将从(1,1)点驶到(n,m) 点,车只能向东或者向北开. 问:司机怎么走能接到最多的乘客。【输入】 第一行是n,m和k,其中k是有乘客的路口的个数。 以下k行是有乘客的路口的坐标和乘客的数量。已知每个 路口

2015-12-17 21:17:42 897

原创 UVA-540 团体队列

分析:和生动运用存储键值为每个人的编号,映照为所在团队;另外设置两个队列,一个存储团队,另一个存储每个团队里的人具体代码:#include #include #include #include using namespace std; const int maxn=1005; int main() { int t,kase=0;

2015-12-17 20:45:23 430

原创 UVA-156 反片语

分析:的生动使用。本题的核心:(1).首先进行标准性处理。(2).的使用,以单词作为键值代码如下#include#include#include#include#include#include#include#include#include#include#includeusing namespace std;string change(string s

2015-12-17 20:33:59 311

原创 UVA-442矩阵链乘

分析:利用栈进行简单的表达式求值,遇到右括号,便弹出栈顶的两个元素,看看是否符合矩阵链乘的规则,符合,便进行运算,之后把结果压入栈中;不符合,跳出。代码如下:#include #include #include using namespace std;struct juzhen{    int a,b;};struct juzhen

2015-12-16 23:08:41 359

原创 UVA 10474 大理石在哪里

分析:又是一个不是太难的题,但是仍可以收获不少东西,sort()的使用,lower_bound函数的使用;本题的核心:先排序再检索代码如下:#include #include #include #include using namespace std;#define maxn 10000int main(){    int v

2015-12-16 23:01:35 418

原创 UVA 10815 安迪的第一个字典

分析:这个题其实是非常水的,但是作为渣滓的我还是从中收获了很多新知识,比如学会了一点的使用,而且知道了在中原来会自动按从小到大的顺序排序。知道了这些,这个题就简单了,只需读入,之后再用迭代器访问挨着输就行了另外,这个题需转换成小写字母,之后再用        stringstream ss(s);        while (ss>>buf) dict.insert

2015-12-16 22:57:48 730

原创 UVA-673平衡括号

分析:栈的应用,遇到右括号便弹出栈顶元素,看是否与右括号相互匹配,其余情况压入栈。(注意:本题有坑,空串空串,为此我跪了数次)代码如下:#include#include#includeusing namespace std;int main(){    int n;    cin>>n;    cin.get();    wh

2015-12-16 22:49:14 1709

原创 UVA-10562看图写树

分析:还是一个DFS的题目,但是这个题的递归条件看起来有点难写,但是只要仔细一想还是可以写出来的。(具体见下面的代码)#include#include#includeusing namespace std;const int maxn = 210;int n;char a[maxn][maxn];void dfs(int r, int c

2015-12-16 22:44:15 401

原创 UVa-10129 单词

分析:欧拉回路的应用欧拉回路:一.无向图欧拉回路:每个顶点度数都是偶数欧拉路:所有点度数为偶数,或者只有2个点度数为奇数二.有向图(非混合)欧拉回路:每个顶点入度等于出度欧拉路:每个顶点入度等于出度;或者只有1个点入度比出度小1, 从这点出发,只有1个点出度比入度小1,从这个点结束,其他点入度等于出度三.混合图(有的边单向,有的边不确定方向)

2015-12-16 22:36:40 355

原创 UVA-439骑士

分析:DFS基础题类似八连快问题,八个方位遍历#include#include#includeusing namespace std;int dir[8][2]={{1,-2},{2,-1},{2,1},{1,2},{-1,2},{-2,1},{-2,-1},{-1,-2}};int m[9][9];void dfs(int x,int y,int

2015-12-16 22:31:00 273

原创 数字三角形【IOI 1994】

分析:DP的基础题   没经过优化的初始代码#include #include #include using namespace std;const int maxn=105;int a[maxn][maxn],f[maxn][maxn];int main(){    int n,m;    scanf("%d",&n);  

2015-12-16 21:36:09 1452

原创 合唱队形

分析:正反遍历两次最长不下降子序列,之后求两次的和的最大值-1便可。(正反遍历多加了一次)代码如下:#include #include using namespace std;const int maxn=1005;int main(){    int f1[maxn],f2[maxn],a[maxn];    int n;    scanf("%d",&n

2015-12-16 20:47:57 410

原创 根据后序和中序回复先序

简单代码如下:(欢迎挑错,初学)Node *NewNode (){    Node *node;    node->left=NULL;    node->right=NULL;    return &node;    }Node * CreateTree(int *mid,int *post,int len){    if (len==0) ret

2015-12-13 20:09:03 255

原创 树的三种遍历方式(递归)

树有三种遍历方式,即先序,中序,后序。初接触树的相关知识,尝试书写一下三种遍历方式的代码先序遍历void xianxu (Node *root ){    if (root)    {        printf("%d", &root->data);        xianxu( root->left);        xian

2015-12-13 19:57:47 711

原创 UVa 839 天平

分析:这是DFS又一个经典题目,符合DFS的理念一路搜到底,再回头。主要难度在于递归边界的书写上。(这个题的类型非常重要)代码如下:#include #include #include using namespace std ;int f= 0 ;int dfs(){    int a,b,c,d ;    scanf("%d%d%d

2015-12-13 12:48:57 345

原创 杭电BC12.12

题解链接:http://bestcoder.hdu.edu.cn/1、GTW likes math 问题描述某一天,GTW听了数学特级教师金龙鱼的课之后,开始做数学《从自主招生到竞赛》。然而书里的题目太多了,GTW还有很多事情要忙(比如把妹),于是他把那些题目交给了你。每一道题目会给你一个函数f(x)=ax2+bx+cf求这个函数在整数区间[l,r]之间的最值。

2015-12-13 00:06:21 273

原创 近期总结

前言:(一个学弱期待在ACM上有所建树的一名大一新生)这是我第三十篇博客,不知不觉,终于能写到三十篇了,这算是一个小小的成就吧,开心一下。今天也是舍友脱单的日子,祝他们能幸福近期总结报告:努力的学了很久,总算是有点进步,没算是虚度这段时间,还是蛮欣慰的。但我也清楚,与名校大一新生相比,自己与他们的差距还是非常大的,加上本校的ACM实力不是非常强,更雪上加

2015-12-12 23:04:08 449

原创 打印图形

题目描述你对迷宫感兴趣吗?现在请你设计一个迷宫,要求你输入一个整形数字n(0方阵。若输入的是5,那么将会输出如下迷宫。迷宫的按字母顺序从外向内旋转,若26个字母用完则从A开始循环使用。A B C D EP Q R S FO X Y T GN W V U HM L K J I输入第一行输入一个整数T,这个数字为测试数

2015-12-10 21:21:48 342

原创 UVa-1583 生成元

分析:水题但有技巧,可以提前打印一个表,之后直接输出值便可代码如下#include #include int ans[100005];int main(){    int T,n;    memset(ans,0,sizeof(ans));    for (int m=1;m    {        int t=m,s=m; 

2015-12-10 20:49:01 435

原创 一二三

题目描述你弟弟刚刚学会写英语的一(one)、二(two)和三(three)。他在纸上写了好些一二三,可惜有些字母写错了。已知每个单词最多有一个字母写错了(单词长度肯定不会错),你能认出他写的啥吗?输入第一行为单词的个数(不超过10)。以下每行为一个单词,单词长度正确,且最多有一个字母写错。所有字母都是小写的。输出对于每

2015-12-10 20:35:49 1007

原创 UVA-264-CountonCantor

分析:这个题起初我直接是挨着遍历的,是的,很麻烦,也很费事费空间,还好这个题数据不是很大,没超时。其实,它是有规律的原始遍历代码#include int main(){    int i,n,j,t1;    while (scanf("%d",&n)!=EOF)    {        int t=1,x=0,y=0,f=1;        for

2015-12-10 20:31:42 318

原创 UVa-272

分析:水题,直接上代码代码如下#include int main(){    int f=1;    char ch;    while ((ch=getchar()!=EOF))    {        if (ch=='"') {printf("%s",f?"‘‘":"''");f=!f;}        else printf("%c"

2015-12-10 20:15:13 538

原创 UVa-679 小球下落

分析:这个题我是没有做出来的,或者说我做出来的那个代码总是超时,看了紫书才明白,原来只需模拟最后一个小球的路线即可。(本题知道小球奇偶性便能判断出他最终会落在那个子树上)代码如下:(完全抄的紫书)#include int main(){    int n,a,b;    long long k;    while (scanf("%d",&n)&

2015-12-10 19:55:50 844

原创 UVa-122 树的遍历

分析:这个题按道理来说是用建立一棵树,之后用BFS搜索来做,然而,我树论和BFS都一窍不通,只能走点歪门邪道,(多方求助终于发现)这个题只需对每个节点的位置排一下序就好了本题多谢多个大神的意见和大神的代码,我才成功做出这个题代码如下:#include #include #include using namespace st

2015-12-10 19:46:11 303

汽水瓶c语言解答

一个简单的小程序,有兴趣可以看看,本人新手一枚,望指教

2015-11-21

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除