自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(149)
  • 收藏
  • 关注

原创 ZOJ1213-Lumber Cutting—动态规划的实现

#include <stdio.h>#include <memory.h>#include <algorithm>using namespace std;struct stBoard{ int number, length; stBoard () {number = 1000;} //木板数量的最优值,初值为∞};bool operator...

2019-12-18 10:24:29 361 1

原创 分支限界算法求解0-1背包问题:不构造最优解,使用struct和优先队列priority_queue

#include<iostream>#include<queue>using namespace std;#define NUM 100struct Node{ int weight; int value; int level; int flag; friend bool operator< (Node a, Node b) { retur...

2019-12-11 15:25:36 262

原创 分支限界算法求解0-1背包问题:不构造最优解,使用struct和queue

#include<iostream>#include<queue>using namespace std;#define NUM 100struct Node{ int weight; //重量 int value; //价值 int level; //层次 int flag; //1是左孩子,0是右孩子 };queue<Node...

2019-12-11 15:08:43 220

原创 01背包,二维数组存储结构

#include<bits/stdc++.h>using namespace std;#define NUM 50#define CAP 1500int v[NUM];int w[NUM];int p[NUM][CAP];int main (){ int W,n; while (scanf("%d", &W) && W) { sca...

2019-12-09 17:46:17 124

原创 01背包,一维数组存储结构

#include<bits/stdc++.h>using namespace std;#define NUM 50#define CAP 1500int v[NUM];int w[NUM];int p[NUM][CAP];int main (){ int W,n; while (scanf("%d", &W) && W) { sca...

2019-12-09 17:38:57 252

原创 半数单集问题

#include<iostream>#include<cstdio>#include<cstring>using namespace std;int a[1005];int HalfSet(int n){ if(a[n]>0) return a[n]; a[n] = 1; for(int i=1; i<=n/2; i++) { ...

2019-12-08 22:53:04 122

原创 链表的基本操作

#include <stdio.h>#include <stdlib.h>#include <string.h>typedef int ElemType; // 定义元素的类型为整型typedef int Status; // 定义状态类型#define ERROR 0#define OK 1typedef struct LNode ...

2019-11-27 15:24:46 256

原创 11.10 ZOJ2836-Number Puzzle—DFS

#include <stdio.h>#include <string.h>int n,m;int vis[11],va[11],cnt;int ans;int gcd(int a,int b){ if(a%b==0) return b; return gcd(b,a%b);}int lcm(int a,int b){ return a/gcd(...

2019-11-19 22:06:33 90

原创 11.10 ZOJ2836-Number Puzzle

#include<stdio.h>int n;int a[110];int GCD(int x, int y) { return y ? GCD(y, x%y) : x;}int LCM(int x, int y) { return x/GCD(x, y)*y;}int multiple(int x, int *cnt) { int i; int re...

2019-11-19 22:02:52 72

原创 PJU2356-Find a multiple

#include <stdio.h>#include <string.h>int main(){ int a[10002]; int s[10002] = {0}; int flag[10002]; int find = 0; int n; int i,j; memset(flag, 0, sizeof(flag)); scanf("%d", &amp...

2019-11-19 22:00:18 100

原创 HDU2048-神、上帝以及老天爷

#include <stdio.h>double a[22]={1,1};double d[22]={0,0,1,2};int main(){ int i,n,m; for(i=1; i<21; i++) a[i] = i*a[i-1]; for(i=3; i<21; i++) d[i] = (i-1)*(d[i-1]+d[i-2]); scanf(...

2019-11-19 21:57:57 88

原创 POJ2084-Game of Connections

#include <stdio.h>int ans[101][101];void catalan(){ ans[0][0] =1; ans[1][0] =1; int i,j,k; int len = 1; for(i = 2; i <= 100; i++) { k = (4*i-2); int carry = 0; for(j = 0; j ...

2019-11-19 21:54:05 121

原创 HDU3625-Examining the Rooms

#include<stdio.h>#include<string.h>#define N 21__int64 fac[N] = {1,1};__int64 stir[N][N];void Factorial_Stirling(){ int i, j; for(i=2; i<N; i++) fac[i] = i*fac[i-1]; memset...

2019-11-19 21:51:33 103

原创 HDU2065-“红色病毒”问题-循环节

#include<stdio.h>#include<string.h>int a[20]={20,72,72,56,60,12,92,56,0,52,12,56,40,92,32,56,80,32,52,56};int main(){ int iCase; __int64 n; while(scanf("%d",&iCase),iCase) {...

2019-11-19 21:48:41 93

原创 HDU2065-“红色病毒”问题

#include<stdio.h>#include<string.h>int fun(int m,__int64 n){ int res = 1; while (n) { if (n&1) res = res*m%100; m = m*m%100; n>>=1; } return res;}int main(){ ...

2019-11-19 21:45:07 112

原创 HDU1521-排列组合

#include<stdio.h>#include<string.h>int main(){ int i; double a[15]; a[0] = a[1] = 1; for(i=2; i<=10; i++) a[i] = i*a[i-1]; int n,m; while(scanf("%d%d",&n,&m)!=EOF) ...

2019-11-19 21:42:21 113

原创 HDU2082-找单词

#include <iostream>#include <cstring>#define MaxN 60using namespace std;int g[MaxN], G[MaxN], x[MaxN];int main(){ int iCase; scanf("%d", &iCase); while (iCase--) ...

2019-11-19 21:37:02 98

原创 HDU1572-X问题

#include<stdio.h>int x,y;int extend_gcd(int m,int b){ if(b==0) { y=0; x=1; return m; } int d = extend_gcd(b,m%b); int t = x; x = y; y = t-m/b*y; return d;}int a[10],b[10];i...

2019-11-12 22:34:14 108

原创 PJU2891-Strange Way to Express Integers

#include<cstdio>#include<iostream>using namespace std;typedef long long LL;LL x,y;LL Extended_Euclid(LL a,LL b){ if (b==0) { y = 0; x = 1; return a; } LL d = Extended_Eu...

2019-11-12 22:30:54 74

原创 ZOJ1160-Biorhythms

#include <stdio.h>int main(){ int p,e,i,d; int N; scanf("%d", &N); while(N--) { int iCase = 1; int lcd = 21252; while (scanf("%d%d%d%d",&p,&e,&i,&d) &&...

2019-11-12 22:25:35 104

原创 PJU3696-The Luckiest number

#include<stdio.h>#include<string.h>#define LL long longLL gcd(LL a,LL b){ return b==0?a:gcd(b,a%b);}//φ(n)LL eular(LL n){ LL ans = n; for (LL i=2; i*i<=n; i++) if (n%i==...

2019-11-12 22:19:59 103

原创 PJU2480-Longge's problem—算法10.6 计算5000以内的素数,筛法

#include <stdio.h>#define MAX 50000__int64 prime[MAX];int pnum = 0;void primtable(){ bool flag[MAX] = {0}; for (int i=2; i<MAX; i++) { if (!flag[i]) { prime[pnum++] = i; f...

2019-11-12 22:14:18 134

原创 PJU2480-Longge's problem

#include <stdio.h>int main(){ int n; while (scanf("%d", &n) != EOF) { __int64 i; __int64 ans = n; int p, a; for (i=2; i*i<=n; ++i) { if (n%i == 0) { a = 0; ...

2019-11-12 22:10:20 88

原创 ZOJ1906-Relatives

#include <stdio.h> int Euler (int n){ int res = n; for (int i=2; i*i<=n; i++) { if (n%i == 0) { n /= i; res = res - res/i; while (n%i == 0) n /= i; } } if (n>1...

2019-11-12 22:06:27 79

原创 算法10.3 实现欧拉函数的算法

int Euler (int n){ int res = n; //任何合数的素因子,不大于 for (int i=2; i*i<=n; i++) { //第一次找到的必为素因子 if (n%i == 0) { n /= i; res = res - res/i; //把该因子全部约掉 while (n%i == 0) n /= i;...

2019-11-12 22:01:17 180

原创 PJU2115-C Looooops

#include <stdio.h>long long x, y;long long Extended_Euclid(long long a, long long b) { if (b == 0) { x = 1; y = 0; return a; } long long d = Extended_Euclid(b, a % b); long long ...

2019-11-12 21:58:27 108

原创 ZOJ2404-Going Home—Kuhn Munkres算法

#include<iostream>#include<cstdio>#include<cstring>#include<vector>#include<cmath>using namespace std;#define INF 1000000#define MAX 105int lx[MAX],ly[MAX]; int...

2019-11-12 21:34:30 237

原创 PJU1247-The Perfect Stall—Hopcroft—Karp算法

#include <cstdio>#include <cstring>#include <iostream>using namespace std;const int MAX=201;const int INF=INT_MAX;struct EDGE{ int b; int next;}edge[2000];int n, m;int ...

2019-11-12 21:31:06 101

原创 ZOJ1140-Courses—Hopcroft—Karp算法—采用vector容器

#include <iostream>#include <cstdio>#include <vector>#include <queue>#include <cstring>using namespace std;#define MAX 305#define INF 0x7fffffffint n,p;int use...

2019-11-12 21:27:53 99

原创 ZOJ1140-Courses—Hopcroft—Karp算法

#include <cstdio>#include <memory.h>#include <queue>using namespace std;const int MAX = 310;const int INF = 1<<8;int p,n;int Cx[MAX], Cy[MAX];int dx[MAX], dy[MAX];int...

2019-11-12 21:24:38 136

原创 PJU1247-The Perfect Stall—匈牙利算法

#include<stdio.h>#include<string.h>#define MAX 205int n,m;int map[MAX][50];int hungary(){ int i,j; int num = 0; int q[MAX]; int match[MAX]; int qs,qe; int cx[MAX],cy[MAX]; m...

2019-11-12 21:20:41 103

原创 ZOJ1140-Courses—匈牙利算法

#include<cstdio>#include<cstring>#include<queue>#include<iostream>using namespace std;#define P 110#define N 310int p;int n;int map[P][N];int match[N];bool use[N];...

2019-11-12 21:15:44 169

原创 ZOJ1137-Girls and Boys—匈牙利算法计算最大匹配数—链式前向星存储结构

#include <cstring>#include <cstdio>#include <iostream>using namespace std;const int MAX=510;struct edge{ int to,next;}e[MAX*MAX];int p[MAX];int match[MAX];bool vist[MAX];...

2019-11-11 23:03:09 207

原创 ZOJ1137-Girls and Boys—匈牙利算法计算最大匹配数

#include <cstdio>#include <cstring>#include <iostream>using namespace std;#define MAX 500int n;int map[MAX][MAX];int match[MAX];int use[MAX];bool DFS(int stu){ for(int i...

2019-11-11 22:59:01 163

原创 ZOJ2404-Going Home—SPFA算法

#include <cstdio>#include <string.h>#include <cmath>#include <queue>#include <iostream>using namespace std;#define MAX 205#define INF 20000int nHouse, nMan, tota...

2019-11-11 22:51:39 132

原创 ZOJ1734-Power Network—Dinic算法-链式前向星存储结构

#include<iostream>#include<cstdio>#include<cstring>#include<queue>using namespace std;const int VM=150;const int EM=20500;const int INF=0x3f3f3f3f;struct Edge{ int...

2019-11-11 20:34:55 147

原创 ZOJ1734-Power Network—使用Dinic算法求解最大消耗电力

#include<cstdio>#include<cstring>#include<queue>#include<iostream>using namespace std;#define inf 99999999#define MAX 120int cap[MAX][MAX];int level[MAX];int n,m,nc,n...

2019-11-11 20:31:24 139

原创 ZOJ1734-Power Network—ISAP算法-链式前向星存储结构

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define inf 0x7fffffff#define N 300#define M 30000int CurrentArc[N];int ...

2019-11-11 20:28:42 145

原创 ZOJ1734-Power Network—ISAP算法

#include<cstdio>#include<cstring>using namespace std;#define MAX 120int n, np, nc, m;int cap[MAX][MAX];int ISAP(int s, int t){ int CurrentArc[MAX]; int level[MAX]; int gap[MAX]...

2019-11-11 20:22:52 125

原创 ZOJ1734-Power Network—Edmonds-Karp算法

#include <cstdio>#include <iostream>#include <string.h>#include <queue>using namespace std;#define MAX 120int n;int np;int nc;int m;int cap[MAX][MAX];int EKarp(int...

2019-11-11 20:17:01 198

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除