
刘汝佳的算法竞赛入门经典
「已注销」
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Master-Mind Hints - UVa 340
Master-Mind Hints - Uva 340 https://vjudge.net/problem/UVA-340 思路: 直接统计A,因为A比较容易统计,相比之下B不容易统计,故要在B上使用一些技巧。 分别统计答案序列与猜测序列中各个数字出现的次数,分别记为c1,c2,选择c1,c2中较小的数,把它给B,直到1~9之间的数字都统计完毕,最后B = B - A,那么,问题来了,为什么这...原创 2019-01-11 10:59:29 · 341 阅读 · 0 评论 -
Flooded! UVA - 815 (sort排序)
错了好多遍,不知道为啥出错,如果有大神发现,请求指点!!! 附错误代码(错的不知道怎么回事): #include<iostream> #include<cstdio> #include<algorithm> using namespace std; const int maxn = 32 + 5; int hblock[maxn*maxn]; ...原创 2019-04-25 15:48:29 · 173 阅读 · 0 评论 -
Integer Inquiry UVA-424(大整数)
题意分析: 将字符串倒着存入int数组中,每次加完后再取余除去大于10的部分 关键:倒着存入,这样会明显缩短代码量。 #include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn = 100 + 10; char s[maxn]; ...原创 2019-04-29 21:06:00 · 197 阅读 · 0 评论 -
Not so Mobile UVA - 839(二叉树的先序遍历)
#include<iostream> using namespace std; int solve(int &W) /*这里一定要用引用,为了赋给它值*/ { int wl, dl, wr, dr; cin >> wl >> dl >> wr >> dr; bool f1 = true, f2...原创 2019-04-29 20:09:24 · 176 阅读 · 0 评论 -
UVA-439, Knight Moves(深度优先搜索)
#include<iostream> #include<queue> #include<cstring> #include<string> #include<cstdio> using namespace std; struct Point { int x_, y_; int route; }; int dic[8][2...原创 2019-04-25 00:32:18 · 170 阅读 · 0 评论 -
Hello World! UVA - 11636(打表)
刚开始忽略了N=1这种情况,所以WA了, #include<iostream> using namespace std; int idx[] = {1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384}; int main() { int N, kcases = 0; while(...原创 2019-04-29 12:42:30 · 207 阅读 · 0 评论 -
Hoax or what UVA - 11136(multiset的应用)
刚开始把题意理解错了,结果样例没过,后来发现每天只处理最大和最小的,其余的不管,也就是说昨天的元素会影响今天的最大值和最小值,如果模拟的话明显会超时,故用multiset,另外发现rbegin()的功能,收获蛮多的。 #include<iostream> #include<set> #include<cstdio> #include<algorithm...原创 2019-04-27 21:54:48 · 173 阅读 · 0 评论 -
Extraordinarily Tired Students, UVA - 12108(模拟)
#include<iostream> #include<cstring> #include<cstdio> using namespace std; int top_line = 1e6 + 10; /*循环次数的上限*/ const int maxn = 10 + 5; int a[maxn]; int b[maxn]; int c[maxn]...原创 2019-04-26 00:09:44 · 215 阅读 · 0 评论 -
The SetStack Computer UVA - 12096
原题链接:https://vjudge.net/problem/UVA-12096 代码转载自:https://blog.youkuaiyun.com/somniloquy_/article/details/47759751 #include <iostream> #include <cstdio> #include <set> #include <map&g...转载 2019-03-03 17:38:14 · 152 阅读 · 0 评论 -
Periodic Strings , UVa 455
原题 附代码: #include<stdio.h> #define MAX 82 #include<string.h> int fun(char str[], int a, int b); int main() { char str[MAX], N; scanf("%d",&N); while(N--) { scanf...原创 2019-01-15 12:32:15 · 161 阅读 · 0 评论 -
MolarMass - UVa1586
原题 附代码: #include<stdio.h> #include<string.h> #define MAX 81 int main() { int T; scanf("%d",&T); while(T--) { char s[MAX]; double ss[] = {0, 0, 12.01, 0,...原创 2019-01-15 10:09:10 · 161 阅读 · 0 评论 -
Circular Sequence, Uva 1584
题目链接 附代码: #include<stdio.h> #define MAX 101 #include<string.h> int fun(char s[], int i, int ch) /*该函数的功能是找到字典序比较小的位置*/ { int j; int n = strlen(s); for(j = 0; j < n; j+...原创 2019-01-14 16:03:50 · 130 阅读 · 0 评论 -
Digit Generator - UVa1583
原题出处 (https://vjudge.net/problem/UVA-1583#author=hanjiangtao) 附代码: #include&lt;stdio.h&gt; #include&lt;string.h&gt; #define MAX 100001 /*定义范围,目的是涵盖所有情况*/ int a[MAX]; /*因范围太大,所以把数组的定义放在外面*/ int main(...原创 2019-01-14 15:01:22 · 137 阅读 · 0 评论 -
生成1~n的排列(模板),生成可重集的排列(对应紫书P184, P185)
生成1~n的排列: #include<iostream> using namespace std; void print_permutation(int n, int *A, int cur) /*n代表这个排列中的元素数*/ { if(cur == n) /*边界*/ { for(int i = 0; i < n; i++) ...原创 2019-05-14 19:37:46 · 303 阅读 · 0 评论