
算法竞赛
文章平均质量分 79
肉鸡小龙
这个作者很懒,什么都没留下…
展开
-
ACM UVA-101
#include <iostream>#include <cstdio>#include <string>#include <vector>using namespace std;const int maxn = 26;vector<int> pile[maxn];int n;void find_block(int a...原创 2018-08-14 20:44:10 · 211 阅读 · 0 评论 -
PAT1001 A+B Format (20 分)(字符串处理)
##题目###分析题目:两个数字相加,然后需要以一定格式输出。先求相加,然后把数字一个个对10取模输出,相对比较容易。用栈做一个后进后出就好了。###代码:#include <iostream>#include <algorithm>#include <stack>using namespace std;stack<char> st...原创 2019-04-20 15:36:20 · 276 阅读 · 0 评论 -
PAT1020 Tree Traversals (25 分)(二叉树的遍历,后序中序转层序)
###题目1020 Tree Traversals (25 分)Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level o...原创 2019-04-20 15:35:42 · 225 阅读 · 0 评论 -
PAT1079 Total Sales of Supply Chain (25)(dfs,树的遍历)
题目A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)– everyone involved in moving a product from supplier to customer.Starting from one root supplier, everyone on t...原创 2019-04-21 08:59:18 · 293 阅读 · 0 评论 -
ccf 201809-3 元素选择器
代码#include <iostream>#include <cstdio>#include <vector>#include <string>#include <algorithm>#include <sstream>#include <queue>using namespace std;s...原创 2019-04-21 08:58:02 · 281 阅读 · 0 评论 -
PAT1043 Is It a Binary Search Tree (25)(二叉查找树BST)
类型二叉搜索树, 先序后序转换题目A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s...原创 2019-04-21 08:57:20 · 207 阅读 · 0 评论 -
CCF201312试题代码
试题:CCF201312试题1.出现次数最多的数分析:因为需要记录数字以及其出现次数,用C++STL中的map,可以简单完成代码:#include <iostream>#include <cstdio>#include <string>#include <vector>#include <deque>#incl...原创 2018-08-19 23:43:45 · 281 阅读 · 0 评论 -
ACM UVA - 400 Unix ls
#include <iostream>#include <string>#include <algorithm>/* run this program using the console pauser or add your own getch, system("pause") or input loop */using namespace std...原创 2018-08-17 01:08:40 · 241 阅读 · 0 评论 -
ACM UVA 816 Abbott's Revenge
#include <iostream>#include <algorithm>#include <cstring>#include <cstdio>using namespace std;/* run this program using the console pauser or add your own getch, system("...原创 2018-08-18 16:48:54 · 225 阅读 · 0 评论 -
ACM UVa 572 Oil Deposits
#include <iostream>#include <cstdio>#include <cstring>/* run this program using the console pauser or add your own getch, system("pause") or input loop */const int maxn = 100 +...原创 2018-08-18 13:20:02 · 210 阅读 · 0 评论 -
ACM UVA - 442 Matrix Chain Multiplication
#include <iostream>#include <stack>#include <string>using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */st...原创 2018-08-17 23:11:52 · 211 阅读 · 0 评论 -
ACM UVA-1225
#include <stdio.h>#include <string.h>int num[10];void count(int a){ char str[6]; sprintf(str, "%d", a); int i = 0; for(i = 0; i<strlen(str); i++) {// printf("%d:%c\n", i, ...原创 2018-08-13 01:06:36 · 194 阅读 · 0 评论 -
ACM UVA1586 Molar mass
#include <stdio.h>#include <string.h>#include <math.h>#define W_C 12.01#define W_H 1.008#define W_O 16.00#define W_N 14.01int ToNum(char *s, int n){ int sum = 0; if(n==0...原创 2018-08-12 23:20:55 · 202 阅读 · 0 评论 -
ACM-变量交换最佳程序
#include<stdio.h>int main(){int a, b;scanf("%d%d", &a, &b);printf("%d %d\n", b, a);return 0;}采用黑盒测试原创 2018-08-08 04:33:18 · 333 阅读 · 0 评论 -
ACM技巧和注意事项
一、注意1.每行输出均应以回车符结束,包括最后一行。除非特别说明,每行的行首不应有空格,但行末通常可以有多余空格。另外,输出的每两个数或者字符串之间应以单个空格隔开。二、技巧1.尽量用const关键字声明常数。2.常数pi, const pi = acos(-1.0)...原创 2018-08-08 04:08:17 · 458 阅读 · 0 评论 -
ACM UVA-156 Ananagrams
#include <iostream>#include <string>#include <vector>#include <algorithm>#include <map>using namespace std;map<string, int> cnt;string repr(const string&a...原创 2018-08-15 10:02:00 · 214 阅读 · 0 评论 -
ACM分数转小数
#include <cstdio>int main (void){ long long a,b; int c; while (scanf ("%lld%lld%d",&a,&b,&c) == 3 && !(a == 0 && b == 0 && c == 0)) { ..原创 2018-08-12 14:20:58 · 618 阅读 · 0 评论 -
PAT1004 Counting Leaves(30)(BFS,DFS,树的层序遍历)
类型:树的遍历,dfs题目:A family hierarchy is usually presented by a pedigree tree. Your job is to count those family members who have no child.InputEach input file contains one test case. Each case starts ...原创 2019-04-20 15:38:31 · 347 阅读 · 0 评论