随笔分类 -  ACM/ICPC

acm 血泪教训
摘要:http://icpc.ahu.edu.cn/OJ/Problem.aspx?id=231#include <iostream> #include <algorithm> using namespace std; int arr[10005]; unsigned long long Fun(int N) { sort(arr, arr + N); unsigned long long ans = 0; for (int i = 0; i < N - 1; i++) { ans += (arr[i + 1] - arr[i]) * (i + 1) * (N - i 阅读全文

posted @ 2012-05-13 19:11 c语言源码 阅读(223) 评论(0) 推荐(0)

priority_queue POJ 3253 Fence Repair
摘要:#include <iostream> #include <queue> using namespace std; int main(void) { priority_queue<double> q; q.push(66.6); q.push(22.2); q.push(44.4); cout << q.top() << ' '; q.pop(); cout << q.top() << endl; q.pop(); q.push(11.1); q.push(55.5); q.push(33.3) 阅读全文

posted @ 2012-05-12 22:54 c语言源码 阅读(184) 评论(0) 推荐(0)

最长递增子序列(LIS) 学习中ing
摘要:单调递增最长子序列描述求一个字符串的最长递增子序列的长度如:dabdbf最长递增子序列就是abdf,长度为4输入第一行一个整数0<n<20,表示有n个字符串要处理随后的n行,每行有一个字符串,该字符串的长度不会超过10000输出输出字符串的最长递增子序列的长度样例输入3 aaa ababc abklmncdefg样例输出1 3 7Accepted #include<stdio.h> int length(char * s) { int len[128] = {0}, i, t; for(; *s != '\0' && (t = len[* 阅读全文

posted @ 2012-04-08 16:39 c语言源码 阅读(540) 评论(0) 推荐(0)

POJ 1163题 数字三角形问题(动态规划)
摘要:http://poj.org/problem?id=11631、普通递归#include <iostream> #include <cstring> #include <cstdio> using namespace std; #define __max(a,b) (((a) > (b)) ? (a) : (b)) #define MAXNUM 101 int N; int aMax[MAXNUM][MAXNUM]; // aMax is memorandum int matrix[MAXNUM][MAXNUM]; int Max(int i, int 阅读全文

posted @ 2012-04-07 19:11 c语言源码 阅读(425) 评论(0) 推荐(0)

NYOJ 2题 括号配对问题
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=21、我的代码: #include <iostream> #include <cstring> using namespace std; #define MAXSIZE 10005 int main(void) { int k; cin >> k; while(k--) { char str[MAXSIZE]; cin >> str; char stack[MAXSIZE]; int len = strlen(str); int j = 0; boo 阅读全文

posted @ 2012-04-04 00:52 c语言源码 阅读(170) 评论(0) 推荐(0)

NYOJ 35题 表达式求值,四则运算(栈实现) 严蔚敏
摘要:这些函数中都有“重复”的,因为操作数(OPND)栈用double,操作符(OPTR)栈用char。C++中的模板可以解决这个问题吗?这是对着书写的:#include <iostream> using namespace std; #define STACK_INIT_SIZE 100 #define STACKINCREMENT 100 char Precede_Matrix[7][7] = { {'>', '>', '<', '<', '<', '>' 阅读全文

posted @ 2012-03-31 22:13 c语言源码 阅读(440) 评论(0) 推荐(0)

等比数列的和
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=3411http://hi.baidu.com/aekdycoin/blog/item/63f633ec11c822d8b21cb168.html 阅读全文

posted @ 2011-05-17 00:33 c语言源码 阅读(344) 评论(0) 推荐(0)

导航