随笔分类 - OJ--UVA
摘要:感觉很巧妙的一道题 之前比赛做过一道题与这个类似 当时没想出来很多蚂蚁在一条线上走 对撞之后改变方向 问T时间之后 蚂蚁分别在哪里 蚂蚁都是一样的 可以把蚂蚁看做一个点 对撞的时候 可以看做穿过 这样T之后哪些点有蚂蚁就知道了 就是不知道这个点的原点是哪个 可以把输入的点排序 因为相对顺序是不变的 就知道这个点原来是哪个了不知道为嘛一直交不对 重新打了一遍 就A了View Code 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm>
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1135好繁琐的一道模拟题 细节很重要 编译错误一次 把字符串结尾写错WA一次 多了getchar()WA一次 多了以空格PE一次 最后AC...3个多小时用了一下map map还是很方便的View Code 1 #include <iostream> 2 #include<map> 3 #include<stdio.h> 4 #include&l
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=341排版问题 错了n次 注意除出来的列有可能为0 不处理为1 会RE 还有如果超过n个字符串 要break 有可能那一列不会满View Code 1 #include<stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 typedef struct node 5 { 6 char c[61];
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=276实在没读懂题意 搜的意思 真佩服UVA的表达能力输入n,表示每个代码的长度为n;输入有多组数据,当n=0时表示结束;而在每组中,以最后输n个0结束。对于每组数据,第一行编码为出题者的(S1,S2,...,Sn),接下来的为猜测者的编码(g1,g2,g3,...gn)。若Si=gj并且i=j,你将得到个A;若Si=gj但i≠j,你将得到B。程序先从1找到n找能得到多少A,然后在找
阅读全文
摘要:题目描写的乱七八糟 就是找无论顺序大小写 不重复出现的字符串 按字典序输出http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=92代码乱七八糟的写的真长View Code 1 #include <stdio.h> 2 #include<string.h> 3 #include<stdlib.h> 4 typedef struct node 5 { 6 char c[25]; 7 int x; 8 }
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1415水题 简单排序查找 快排+哈希View Code 1 #include <stdio.h> 2 #include<string.h> 3 int cmp(const void*a,const void *b) 4 { 5 return *(int *)a-*(int *)b; 6 } 7 int main() 8 { 9 int i,j,n, m, a
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=98&page=show_problem&problem=1361题不难 我交了八次。。 刚开始以为还要判断一个国家会不会重复妇女的名字 写的复杂了 一直runtime 看了下别人的代码 知道不用判断 删去了一大部分 之后开始WA 最后找到原因 是因为除国家外 因为不确定名字的字符串数 名字用gets输入开两个数组 一个存国家 一个存数量 有输入重复的国家 就剪掉View Code 1 #include &l
阅读全文
摘要:纠结了好几个小时 不明白哪错了 跟别人的代码仔仔细细的对照才发现题目要求把原来的数据再输出一遍 石化。。选择排序的思想 每次找到最大的那个数将它放在该放的位置输入用字符串 再转化成数字UVA就是麻烦 来来回回的逆转 都转晕了View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<string.h> 4 int n ; 5 void deal(char *s,int *a) 6 { 7 int begin,end,len=strlen(s); 8 n=0; 9 begin=0;10 end
阅读全文
摘要:题目地址http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1435前面一个是大数需要字符串来存 后面一个定义long型就够了 计算的时候就是边做边把字符转换为数字取余比较简单一点 可以边转边取余 转完输出结果就行了除法 模拟手算 从头找 找第一个能被它整除的那一位 找到之后 就依次除就行了 除的结果存在一个整型数组里#include <stdio.h>#include <stdlib.h>#include&l
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=96&problem=1056&mosmsg=Submission+received+with+ID+10189080纠结了 两天的一道题 由于字符串函数没用对 就一直做不对 搜了下解题报告 终于知道该怎么用了。View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=1819这个题找到规律就很好做,就是相当于二进制,o代表1,空格代表0,然后算出来为字母的ASCII码,输出就行了。View Code 1 #include <stdio.h> 2 #include <math.h> 3 #include<string.h> 4 int main() 5 { 6 int i,j,k;
阅读全文
摘要:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1756这个题错了十几次 runtime 占了10次 错了一天 最后终于改对了 用一个小数组把单词存起来 然后把这个单词复制给一个二维数组,复制的时候查找一下前面是否有重复的 如果没有就复制给它,然后用快排对所有的进行排序。View Code 1 #include <stdio.h> 2 #include<string.h> 3 #include<std
阅读全文
摘要:题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=585找一个字符串是否是另一个的前缀 ,我用了一个字符串函数,然后比较了下就行了View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<string.h> 4 int main() 5 { 6 int i,j,g,k,n,m,f = 0,q = 0,flag; 7 char
阅读全文
摘要:题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=350找下面的句子中上面关键词出现的最多的句子 一样多的话按给的顺序输出将下面的句子分解成小的只含字母字符串 然后依次与上面查找比较 找出数量最多的就行View Code 1 #include <stdio.h> 2 #include<string.h> 3 struct node 4 { 5 char c[25]; 6 int flag; 7 }; 8
阅读全文
摘要:题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=96&page=show_problem&problem=478依次搜查就行了 要注意m,k,M这几个不是标准单位 要进行换算一下,写着有点麻烦,多注意一些。View Code 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include<string.h> 4 char c[1001]; 5 float swit(char
阅读全文
摘要:题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1302题目大意就是在<之后的字符串用二维数组存起来 一直到最后 输出的第一行就是把输入的<和>去掉然后输出 第二行 把省略号 用刚才存的数组代替 除了最后一个字符串 其它的都倒着输出 输完再把最后一个字符串输出。View Code 1 #include<stdio.h> 2 #include<string.h> 3 int main()
阅读全文
摘要:题目http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=951就是从每个字符的8个方向循环找是否有跟给出的字符串相等的 找的时候稍微限制一些条件即可 代码有点长View Code 1 #include<stdio.h> 2 #include<string.h> 3 int main() 4 { 5 int t, n, m, k, y, i, j,f,x,w,v,flag,g,o; 6 char c[55][55
阅读全文