解题报告
文章平均质量分 80
Tilmant
1:1The words of Nehemiah the son of Hachaliah. And it came to pass in the month Chisleu, in the twentieth year, as I was in Shushan the palace,1:2That Hanani, one of my brethren, came, he and certain men of Judah;
展开
-
HDU 1413 文件系统 (数据结构)
心得: 一道比较基础的数据结构题,没什么算法可言,关键是要熟练各种数据结构的各种操作,其次还要有耐心。 传送门:HDU1413#include <iostream>#include <string.h>#include <stdio.h>using namespace std;struct directory //一个文件系...原创 2016-12-24 16:40:19 · 543 阅读 · 0 评论 -
二叉树入门:PAT 1020& HDU 1710& UVa 536(数据结构)
二叉树是数据结构中很重要的一部分,树的四种遍历: 前序,中序,后序,层次 涉及到了递归与队列的使用(当然也有非递归的遍历) 通过中序&前序或者中序&后序构建二叉树是一类很常见的考察方式 所以最好还是把所有的内容都实现一遍 写了三天的BUG今天终于能跑动了(ಥ _ ಥ) 本来的计划是按面向对象的方法实现节点类和树类,各种实现方式用成员函数表达,建树过程希望能用一个buil...原创 2018-08-06 20:15:19 · 223 阅读 · 0 评论 -
UVa 524 Prime Ring Problem(回溯)
传送门 A ring is composed of n (even number) circles as shown in diagram. Put natural numbers 1, 2, … , n into each circle separately, and the sum of numbers in two adjacent circles should be a prime....原创 2018-08-14 15:31:10 · 153 阅读 · 0 评论 -
2013年中南大学计算机研究生复试机试题解
高温假闲着无聊,在voj上把CSU的机试题 刷了一道,可能是因为题目年代比较久远,题目的难度并不是很大。稍稍整理一下,希望以后用得着。1264: 惠民工程所有题目中唯一的数据结构题 MST问题的解法很多Prim,Kruskal比较常见 此外还可以用并查集解 因为本人正在复(预)习数据结构,所以用Prim求解 Kruskal和并查集方法以后有时间再放吧……(估计是不得写了)传...原创 2018-08-02 18:05:53 · 2266 阅读 · 3 评论 -
UVa 1584 Circular Sequence(模拟)
模拟策略: 化曲为直 模拟的方式有点像动态规划: 将环形序列复制模拟环的结构 再枚举出字典序最小的序列 传送门 Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence “CGAGTCAGCT”, that is, the last s...原创 2018-08-11 20:21:55 · 125 阅读 · 0 评论 -
UVa 455 Periodic Strings(字符串处理)
传送门 A character string is said to have period k if it can be formed by concatenating one or more repetitions of another string of length k. For example, the string ”abcabcabcabc” has period 3, since...原创 2018-08-11 20:26:51 · 132 阅读 · 0 评论 -
UVa 1586 Molar mass(模拟)
模拟思路: 有点像词法分析器里面的超前搜索 出现数字肯定之前是有元素的 如果出现了数字那么看它是两位数还是一位数 结合之前的化学元素算质量 默认元素个数为一 传送门 An organic compound is any member of a large class of chemical compounds whose molecules contain carbon. The...原创 2018-08-11 20:34:57 · 181 阅读 · 0 评论 -
UVa 673 Parentheses Balance(数据结构)
传送门 You are given a string consisting of parentheses () and []. A string of this type is said to be correct: (a) if it is the empty string (b) if A and B are correct, AB is correct, (c) if A is co...原创 2018-08-15 15:08:29 · 217 阅读 · 0 评论 -
PAT 1045 Favorite Color Stripe(LCS)
本来是本着水水更健康的心态做这道题的,结果做得心态炸裂,PAT里面C++不支持gets(),用fgets()爆内存RE。题意很简单,就是求允许重复的LCS长度,但是输入有点坑,自己写的有两个测试点RE了,看了看别人的AC代码直接用vector做的,被输入卡住可以说很气了(╯▔皿▔)╯ 传送门 Eva is trying to make her own color stripe out of a...原创 2018-08-13 16:15:26 · 282 阅读 · 0 评论 -
图论基础之Union Find
ConceptUnion Find通常被翻译为并查集,让人听起来觉得非常高深莫测,为此,我给它起了个外号 叫做:“认祖宗”! 没错,寻找根节点的过程难道不就叫“认祖宗”吗? 我们可以把图论中的一些术语用日常生活用语联系起来: 节点:形形色色的人 边:父子关系 根:一群人的祖宗 并查集就是把一群人用一种算法分成不同家族。 其中一个重要的过程就是认亲。 所以,并查集有如下几个要素...原创 2018-08-09 20:57:24 · 421 阅读 · 0 评论 -
HDU 3257 Hello World!(位运算&模拟)
神头鬼脸的位运算 (●ˇ∀ˇ●)o(^▽^)o 传送门 Problem Description Your task is to print … er … “Hello World” … in a fantastic way – using a beautiful font.I’ve sent you a nice font for you to use, but I’m too bus...原创 2018-07-30 22:10:25 · 288 阅读 · 0 评论 -
牛客练习赛23--(A)托米的赌球(贪心)
传送门 因为题目所给的数值与市面上人名币面额相同,所以任意金额的钱都可以凑出(小学数学老师说的我也不知道为什么╮(╯-╰)╭) 所以贪心一下就有了#include <stdio.h>int main(){ int a,b,c[7] = {100,50,20,10,5,2,1},t; scanf("%d",&t); while(t原创 2018-07-29 13:37:54 · 260 阅读 · 0 评论 -
动态规划入门
(A)–POJ1163 The Triangle传送门 找状态转移方程:从后往前找最大 t[i][j] += max(t[i+1][j],t[i+1][j+1]) 终态: t[1][1]#include <stdio.h>#include <algorithm>using namespace std;原创 2018-07-29 15:49:56 · 158 阅读 · 0 评论 -
GPLT L1-054 福到了(找规律&模拟)
传送门 比赛时没写出,很气(╯▔皿▔)╯ 可能还是熟练度不够#include <stdio.h>#include <string.h>int main(){ char ch,s[128][128],ans[128][128],t[128][128]; memset(ans,0,sizeof(ans)); memset(原创 2018-07-29 15:54:48 · 184 阅读 · 0 评论 -
PAT 1007 素数对猜想(素数&暴力)
传送门 筛法素数打表->枚举 ╮(╯-╰)╭#include <stdio.h>#include <math.h>#include <string.h>#define INF 1<<20int main(){ long long i,j; char isPrime[INF]原创 2018-07-29 15:59:13 · 127 阅读 · 0 评论 -
PAT 1008 数组元素循环右移问题(找规律)
传送门 找规律╮(╯-╰)╭ 一个数组A中存有N(N&gt0)个整数,在不允许使用另外数组的前提下,将每个整数循环向右移M(M>=0)个位置,即将A中的数据由(A~0~ A~1~……A~N-1~)变换为(A~N-M~ …… A~N-1~ A~0~ A~1~……A~N-M-1~)(最后M个数循环移至最前面的M个位置)。如果需要考虑程序移动数据的次数尽量少,要如何设计移动的方法?...原创 2018-07-29 16:10:06 · 124 阅读 · 0 评论 -
PAT 1027 打印沙漏(找规律)
传送门 本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印*所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。输入格式:输入在一行给出1个正整数N...原创 2018-07-29 16:13:21 · 167 阅读 · 0 评论 -
搜索入门:POJ 2386 Lake Counting& UVa 572 Oil Deposits(DFS模板)
利用二维数组所搜 (●’◡’●) int dir[8][2] = {{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{-1,1},{1,-1},{1,1}};void dfs(int x,int y){ for(int i=0; i<8; i++) { int dx = x+dir[i][0]; int dy ...原创 2018-07-29 17:04:05 · 210 阅读 · 0 评论 -
排序算法
插入排序//1:insertsorttemplate <typename T>void InsertSort(T a[], int n){ for (int i = 1; i < n; i++) { T t = a[i]; int j = i - 1; while (j >= 0 && ...原创 2019-09-16 17:10:21 · 204 阅读 · 0 评论