算法
算法题解析
easy-learning
快乐学习~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
大理石在哪(Where is the Marble?, uva 10474)
排序之后可以用lower_bound 查找大于或等于x的第一个元素的位置 // uva10474.cpp #include <iostream> #include <algorithm> using namespace std;const int MAX = 10001; int marble[MAX]; int main(){ int N, Q, kase = 0; while((原创 2017-07-20 19:20:03 · 287 阅读 · 0 评论 -
安迪的第一个字典(Andy's First Dictionary, UVa 10815)
int tolower(int ch)的使用要特别小心, 参数ch必须是unsigned char 或者 EOF 字符串大小写转换很常用,因此折腾了一下transform的使用 // uva10815.cpp #include <iostream> #include <string> #include <cctype> #include <algorithm> #include <set> #inc原创 2017-07-24 21:24:39 · 530 阅读 · 1 评论 -
反片语(Ananagrams, UVa 156)
学习了map用法, 特别是count的用法:size_type count (const key_type& k) const; Count elements with a specific key. Searches the container for elements with a key equivalent to k and returns the number of matches. r原创 2017-07-25 21:18:21 · 356 阅读 · 0 评论 -
洪水(Flooded! uva815)
这题比较简单, 但要注意数据类型。// uva815.cpp #include <stdio.h> #include <string.h> #include <algorithm> #define MAX 1000000 #define MAXN 900 int elevation[MAXN]; int main(){ int n, m, kase = 0; while (scanf原创 2017-07-19 21:40:50 · 409 阅读 · 0 评论 -
木块问题(The Blocks Problem, UVa 101)
我用了迭代器// uva101.cpp #include <vector> #include <iostream> #include <string> using namespace std; const int MAX = 30; vector<int> pile[MAX]; vector<int> tmp; int n; int find(int a){ for(int b = 0; b原创 2017-07-22 19:47:16 · 489 阅读 · 0 评论 -
象棋(Xiangqi, uva1589)
检查黑方能走到位置时应排除被黑方吃掉的棋子。 // uva1589.cpp #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #define MAXN 10 struct piece { int x; int y; } pieces[MAXN];char board[12][12]; /原创 2017-07-18 18:45:14 · 500 阅读 · 0 评论 -
数据挖掘(Data Mining, uva1591)
本题主要在于理解题意,Q数组可以不连续存储指的是只要公式能够满足即可, 不一定有规律的存储。比如,先11个byte存储数据,1个byte空闲,再12个byte存储数据, 1个byte空闲。简单计算可以得出K >= Sq * N为充要条件 测试数据Northeastern Europe (NEERC)2003 // uva1591.cpp #include <stdio.h> #include <st原创 2017-07-18 14:50:22 · 615 阅读 · 0 评论 -
uva12108 特别困的学生 (Extraordinary Tired Students
简单粗暴地判断不存在“全部都清醒的状态”// uva12108.cpp #include <stdio.h> #include <string.h> #define MAXN 12 // 1 for awaken state of students, 0 for sleep struct student { int a; int b; int c; // c for stat原创 2017-07-16 20:08:34 · 437 阅读 · 0 评论 -
uva509 RAID
1.#include <bits /stdc++.h>包含了目前c++所包含的所有头文件 2. b = 1时也有校验码 3. 没有使用多少位运算。。。 // uva509.cpp #include <stdio.h> #include <string.h> #define DISKS 8 #define SIZE 80 #define BLOCKS 120 struct dis {原创 2017-07-15 20:50:14 · 395 阅读 · 0 评论 -
uva508 莫尔斯电码(Morse Mismatches)
首先我理解错了题意,在这篇文章找到了UVa 508 Morse Mismatches(莫尔斯电码) 这题的意思是给定一些莫尔斯编码,给定一些已知字典,给定一些编码,求解这些编码的对应原文,如果可以精确匹配,则直接输出原单词,如果有多个可精确匹配的结果,则输出匹配结果里字典序最小的单词(紫书上说输出任意一个,这是错误的)并在末位加上“!”;如果无法精确匹配,则可以在编码的末尾增加或删除一些字符后匹配原创 2017-07-14 19:26:50 · 761 阅读 · 0 评论
分享