[Algorithm]
文章平均质量分 77
O0o王钰o0O
ACM爱好者
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
[Brief Introduction to Data Structure]Linear Table- 线性表
线性表分为顺序存储结构和链式存储结构。1.顺序存储结构特点:逻辑结构和存储结构(物理结构一致) 可以随机存取,访问每个元素所用时间相同 插入或删除效率低2.链式存储结构特点:逻辑结构和存储结构不一定相同。 不能随机存取,访问每个元素时间不同 插入或删除效率高。原创 2013-03-13 18:01:25 · 821 阅读 · 0 评论 -
Interval Intersections
Interval IntersectionsTime Limit: 1000 MS Memory Limit: 65536 KbTotal Submission: 484 Accepted: 178Description给定x 轴上n 个闭区间。去掉尽可能少的闭区间,使剩下的闭区间都不相交。给定n 个闭区间,编程计算去掉原创 2013-06-05 15:26:04 · 785 阅读 · 0 评论 -
Program storage
Program storageTime Limit: 1000 MS Memory Limit: 65536 KbTotal Submission: 701 Accepted: 298Description设有n 个程序{1,2,…, n }要存放在长度为L的磁带上。程序i存放在磁带上的长度是 Li,程序存储问题要求确定这n 个程序在磁带上的一个存储方案,使得能够在磁带上存储尽可能多的程原创 2013-06-05 15:24:15 · 811 阅读 · 0 评论 -
Oil Car
Oil CarTime Limit: 1000 MS Memory Limit: 65536 KbTotal Submission: 1492 Accepted: 361Description一辆汽车加满油后可行驶n公里。旅途中有若干个加油站。设计一个有效算法,指出应在哪些加油站停靠加油,使沿途加油次数最少。对于给定的n原创 2013-06-05 15:21:58 · 1015 阅读 · 0 评论 -
[Dynamic Programming]Recursion/Non-recursion to find the max number
//国际大学生程序设计竞赛例题解(三) //动态规划 //Page107Recursion Version#include #include using namespace std;int data[100];int getMax(int left, int right){ if(left == right) { retu原创 2013-05-13 16:03:47 · 749 阅读 · 0 评论 -
[Templates That Are Usually Used]Greatest Common Divisor
#include #include #include using namespace std;int gcd(int a, int b){ int ans; if(a < b) swap(a, b); if(b == 0) ans = a; else ans = gcd(b, a%b); return ans;}原创 2013-05-13 13:07:44 · 716 阅读 · 0 评论 -
[Templates That Are Usually Used]Header Files Include and Pre-Process(ToBeContinued)
#include #include #include #include #include #include #include #include #include #define LL long long#define rep(i, n) for(int i = 0; i < n; i++)原创 2013-05-13 13:10:54 · 951 阅读 · 0 评论 -
[Dynamic Programming]Route choices
//国际大学生程序设计竞赛例题解(三) //动态规划 //Page 110#include #include using namespace std;const int MAXSIZE = 100;int f[MAXSIZE][MAXSIZE];int main(){ int x, y; for(int i = 0; i < MAXSIZE原创 2013-05-13 16:38:09 · 738 阅读 · 0 评论 -
[Templates That Are Usually Used]Least Common Multipler
#include #include #include using namespace std;int gcd(int a, int b){ int ans; if(a < b) swap(a, b); if(b == 0) ans = a; else ans = gcd(b, a%b); return ans;}原创 2013-05-13 13:09:30 · 687 阅读 · 0 评论 -
[Dynamic Programming]Example 3.1 Recursion Programming - About the Stairs
//国际大学生程序设计竞赛例题解(三)//动态规划//Page104Version 1.0#include #include using namespace std;int f(int n){ int ret; if(n == 0) ret = 1; else if(n == 1) ret = 1; else {原创 2013-05-13 14:34:59 · 761 阅读 · 0 评论 -
[Dynamic Programming]Example 3.1.2-Permutation of Number Sequence
//国际大学生程序设计竞赛例题解(三) //动态规划 //Page106///例题3.1.2#include #include using namespace std;void swap(int &x, int &y){ int temp = x; x = y; y = temp;}int n;int data[100];void s原创 2013-05-13 15:23:43 · 902 阅读 · 0 评论 -
[水题一枚][BOJ]1018-Campus Singing Contest
非常简单的题,输入之后统计一下就行。。。#include#includeusing namespace std;struct cand{ string name; int vote;}cand[110];int main(){ int n; while(cin >> n) { for(int i = 1; i <= n;原创 2013-04-24 13:13:48 · 1028 阅读 · 0 评论 -
[POJ][3517]-Joseph Circle-01
#includeusing namespace std;int dp;int main(){ int n, k, m, i; while(scanf("%d%d%d", &n, &k, &m)){ if(n == 0 && m == 0 && k == 0) break; dp = 0; for(i = 2; i < n; i+原创 2013-03-19 21:27:31 · 679 阅读 · 0 评论 -
[Data Structure][Tree][Binary Tree]POJ 2255----Tree Recovery
非常经典的一道二叉树题目运用递归建立二叉树1.前序序列中pre[0]为二叉树的根节点2.中序序列中root所在位置的两侧分别为左子树和右子树3.运用递归建立以结构体为节点的二叉树,指针域包含左孩子和右孩子题目链接:http://poj.org/problem?id=2255#include#includeusing namespace std;struct n原创 2013-07-31 19:48:04 · 969 阅读 · 0 评论
分享