上一页 1 ··· 5 6 7 8 9 10 11 下一页
摘要: #include#include#define max(x,y) x>y?x:y#define MAXX 100005int num[MAXX] = {0};int mum[MAXX] = {0};int sum[2][MAXX] = {0};int comp ( const void *a, co... 阅读全文
posted @ 2014-01-28 22:57 天I火 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 一、01背包问题问题描述:有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。 所谓01背包,表示每一个物品只有一个,要么装入,要么不装入。测试数据:有一个背包体积为10,有6件物品:解题报告图解:代码:#include#defin... 阅读全文
posted @ 2014-01-28 14:21 天I火 阅读(130) 评论(0) 推荐(0) 编辑
摘要: #include#include#includeusing namespace std;int pre[100005];vectorv[100005];void DFS(int cur){ for(int i = 0; i < v[cur].size(); ++i) { if(pre[v[cur... 阅读全文
posted @ 2014-01-23 12:18 天I火 阅读(135) 评论(0) 推荐(0) 编辑
摘要: #includevoid dfs(int step,int x,int y);int d[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};int mg[9][9]={1,1,1,1,1,1,1,1,1, 1,0,0,1,0,0,1,0,1, ... 阅读全文
posted @ 2014-01-22 22:01 天I火 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 1、把一个二进制的串转换为十进制整数#include#includeint main(){ long long n; long long k=0; long long m=0; while(scanf("%lld",&n)!=EOF){ while(n){ k=k+(n%10)*pow(2,m... 阅读全文
posted @ 2014-01-21 22:54 天I火 阅读(138) 评论(0) 推荐(0) 编辑
摘要: (1)区间完全覆盖问题问题描述:给定一个长度为m的区间,再给出n条线段的起点和终点(注意这里是闭区间),求最少使用多少条线段可以将整个区间完全覆盖样例:区间长度8,可选的覆盖线段[2,6],[1,4],[3,6],[3,7],[6,8],[2,4],[3,5]解题过程:1将每一个区间按照左端点递增顺... 阅读全文
posted @ 2014-01-21 12:13 天I火 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 这道题目就是,找规律,小学奥数,找规律不难吧,#includeint sc(int x);int main(){ int n=0; int num,cs,k; scanf("%d",&n); while(n--){ scanf("%d",&num); k=(sc(num)-1)*sc(num)... 阅读全文
posted @ 2014-01-17 21:42 天I火 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 典型的大数题目,这只是大数的比较,到时还有大数加减乘除,更加还有乘方,对于大数,一般用数组或者字符串,因为其他的结构类型一般都没有那么大 的范围!!这道题目需要你仔细回想怎么比较俩个数字的大小,考虑各种情况。例如:符号的不同,位数的不同等,#include#includeint pd(char s1... 阅读全文
posted @ 2014-01-17 21:29 天I火 阅读(129) 评论(0) 推荐(0) 编辑
摘要: #includeint main(){ long x,y; char op; int t; scanf("%d ", &t); while (t--) { scanf("%x%c%x", &x, &op, &y); if (op == '+') printf("%o\n", x+y); ... 阅读全文
posted @ 2014-01-17 21:11 天I火 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 动态规划,基本上就是说:你追一个MM的时候,需要对该MM身边的各闺中密友都好,这样你追MM这个问题就分解为对其MM朋友的问题,只有把这些问题都解决了,最终你才能追到MM。该方法适用于聪明的MM,懂得“看一个人,不是看他如何对你,而是看他如何对他人。”的道理,并且对付这样的MM总能得到最优解。该方法的... 阅读全文
posted @ 2014-01-16 21:34 天I火 阅读(134) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 下一页