- 博客(21)
- 收藏
- 关注
原创 HDU2111
贪心排序#include #include #include using namespace std;const int N = 105;int v, n, sum;struct bag{ int pi, mi;}b[N];bool cmp(const bag& a, const bag& b) { return a.pi > b.pi;}
2014-04-22 21:17:09 735
原创 HDU1257
贪心#include #include #include #include using namespace std;const int N = 1005;int n, arr[N];int main() { while (scanf("%d", &n) != EOF) { for (int i = 0; i < n; i++)
2014-04-14 20:09:58 547
原创 UVA1344 - Tian Ji -- The Horse Racing
题意:田忌赛马,求出能赢的最大的钱数思路:#include #include #include #include using namespace std;const int N = 1005;int a[N], b[N];int main() { int n; while (scanf("%d", &n) && n) { for
2014-04-14 16:51:38 583
原创 HDU1050
#include #include #include #include using namespace std;const int N = 205;int vis[N];int main() { int cas; int time; scanf("%d", &cas); while (cas--) { int n;
2014-04-14 16:49:19 602
原创 HDU1049
题意:青蛙#include #include #include using namespace std;int n, u, d, cnt;int main() { while (scanf("%d %d %d", &n, &u, &d) && n && u && d) { int a, flag; cnt = a = flag
2014-04-14 16:47:29 509
原创 HDU1009
思路:贪心#include #include #include #include using namespace std;const int N = 1005;struct state{ double a, b, c;}s[N];bool cmp(const state& a, const state& b) { return a.c > b.
2014-04-14 16:45:25 570
原创 UVA10986
题意:给出n,m,s,t,n表示有n个点,m表示有m条边,然后给出m行数据表示m条边,每条边的数据有连接两点的序号以及该边的权值,问说从点s到点t的最短路径是多少。思路:分析题目的样列可知,这一题是要用邻接矩阵来存储无向图,所以要注意无向图怎么存储在邻阶表。连接表的横列有N项,纵列也是N项。形成的N*N项每项都被称为边结点,每项都有纵横两个坐标,例如点(N,N-1),表示的就是从第N点向第N-
2014-04-14 16:37:37 752
原创 POJ2377
#include #include #include #include #define N 100005using namespace std;struct state{ int l, r, value;}s[N];int n, m, cnt;int f[N], sum;bool cmp(const state& a, const state& b) {
2014-04-14 16:30:29 624
原创 UVA10397- Connect the Campus
#include #include #include #include #include #define N 600005using namespace std;struct state{ int l, r; double value; }s[N];int n, m, cnt, f[N], x[N], y[N];double sum;bool cmp
2014-04-14 16:28:49 527
原创 UVA10369- Arctic Network
#include #include #include #include #include #define N 250005using namespace std;struct state{ int l, r; double value;}s[N];int n, m, cnt, f[N], x[N], y[N];double ans;bool cmp(c
2014-04-14 16:24:21 549
原创 UVA10099- The Tourist Guide
#include #include #include #include #define N 10005using namespace std;struct state{ int l, r, value;}s[N];int n, m, k, t, d, ans1, ans2;int f[N];bool cmp(const state& a, const state
2014-04-14 16:21:45 620
原创 UVA10048- Audiophobia
#include #include #include #include #define N 10005using namespace std;struct state{ int l, r, value;}s[N];int n, m, f[N];int getFather(int x) { return x == f[x] ? x : f[x] = getF
2014-04-14 16:17:19 538
原创 UVA10608
计算出集合中元算#include #include #include #define N 30000using namespace std;int cas, n, m, ans;int father[N], cnt[N]; void init(int n) { for (int i = 1; i <= n; i++) { father[i] =
2014-04-14 16:03:44 585
原创 UVA11987- Almost Union-Find
#include #include #include #define N 100005using namespace std;int f[N * 2], cnt[N * 2], sum[N * 2];int n, m, a, b, k;void init() { for (int i = 1; i <= n; i++) { f[i] = i + n;
2014-04-14 16:00:07 568
原创 POJ1611
计算被感染人的数量,shui t#include #include #include using namespace std;const int N = 30005;int f[N], num[N], arr[N];int n, m;void init() { for (int i = 0; i < n; i++) { f[i] = i
2014-04-14 15:55:09 707
原创 POJ2524
并查集模版,水题#include #include #include using namespace std;const int N = 50005;int f[N];int n, m;void init() { for (int i = 1; i <= n; i++) f[i] = i; }int find(int x) { re
2014-04-13 22:00:15 704
原创 POJ1182食物链
http://hi.baidu.com/tomspirit/item/d1f2a19b2aaf36d27a7f0158http://cavenkaka.iteye.com/blog/1489588两个参考的博客。#include #include #include using namespace std;const int N = 50005;int f[N
2014-04-13 21:27:03 557
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人