#include <iostream> #include <stdio.h> #include <stdlib.h> using namespace std; int num; int a[10]={0}; int f() { for(int i=1;i<=num;i++) { int
Category: ACM
批处理作业调度问题的分支限界法
1 题目 n个作业{1, 2, …, n}要在两台机器上处理,每个作业必须先由机器1处理,然后再由机器2处理,机器1处理作业i所需时间为ai,机器2处理作业i所需时间为bi(1≤i≤n),要求确定这n个作业的最优处理顺序,使得从第1个作业在机器1上处理开始,到最后一个作业在机器2上处理结束所需时间最少。 2 代码 #include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <queue> #define MAX
世界名画陈列馆问题的分支限界法
#include<iostream> #include<stdio.h> using namespace std; class Monitor{ int m,n; char **Matrix; int *Place; public: Monitor(){} Monitor(int m,int n){ int i,j,room,x,y;
最优二叉查找树-optimal binary search tree-dynamic programming
//最优二叉查找树-optimal binary search tree-dynamic programming //tree node 1,2,..,n //freq w1,w2,..,wn //dp[i][j]->cost of subtree formed by i,i+1,..,j, inclusive #include <stdio.h> #include
使用队列,打印杨辉三角
#include <stdlib.h> #include <stdio.h> #include “Conio.h” #define MAX 15 #define LINE 10 typedef int ElemType; typedef struct { ElemType data[
使用顺序栈,将一个十进制整数转换为x进制。
#include <stdio.h> #include <stdlib.h> #define MAX 100 typedef int Elemtype; typedef int status; typedef struct { Elemtype base[MAX]; int top;
x^A=B(mod C)的解 (离散对数与原根)
x^A=B(mod C)的解 (离散对数与原根) #include <iostream> #include <string.h> #include <algorithm> #include <stdio.h> #include <math.h> #include <bitset> #include <map> using namespace std;
n的二进制表示中1的个数的乘积
设 sum(i) 表示 i 的二进制表示中 1 的个数。给出一个正整数 N ,求 sum(1)至sum(N) 的乘积。 #include <iostream> #include <string.h> #include <stdio.h> using namespace std;