上一页 1 2 3 4 5 6 ··· 14 下一页
摘要: 转解题报告:http://hi.baidu.com/1996102129/blog/item/6e6fcd50853bb814367abec1.html/cmtid/a69829e65dc5e920b93820fd 我觉得这题的难点是彻底读懂题目,确实难读懂。实话。 我的代码如下:#include <stdio.h>#include <stdlib.h>#define max(a, b) ((a)>(b)?(a):(b))int coin[1001][1001], sum[1001][1001];int cost[1001], f[1001];int main(i 阅读全文
posted @ 2011-08-24 14:08 zqynux 阅读(377) 评论(0) 推荐(0) 编辑
摘要: 这题我还是没看太懂,准确的说是不知道方程是不是正确的,但是隐隐约约感觉又是对的额,嗯……题解的网站发上来吧,你们自己看去吧。 http://hi.baidu.com/greeeeeeen/blog/item/9ae3b0fa52241d939f51468c.html 代码如下:#include <stdio.h>#include <stdlib.h>int t[5001], f[5001];int c[5001];int main(int argc, char **argv){ int i, j; int n, s; int a, b; scanf("%d%d 阅读全文
posted @ 2011-08-23 10:36 zqynux 阅读(187) 评论(0) 推荐(0) 编辑
摘要: 嗯,看网上的题解吧,我推荐一个,觉得不错的,不贴上来了,直接放地址:http://hi.baidu.com/qq953892596/blog/item/4c17eb807c98c8b20cf4d202.html 代码:#include <stdio.h>#include <stdlib.h>#define min(a, b) ((a)<(b)?(a):(b))int left[1001][1001], right[1001][1001];int w[1001][1001];struct girl{ int d, w;}girls[1001];int n;void 阅读全文
posted @ 2011-08-22 22:52 zqynux 阅读(490) 评论(0) 推荐(0) 编辑
摘要: 直接搜就是了,一个点向根出发,到的每个都记录一下,然后另一个点再搜,第一个被标记的就是了。#include <stdio.h>#include <stdlib.h>int p[1000001];int time[1000001];void srch(int i){ while(i != 1){ time[i] = 1; i = p[i]; } time[i] = 1;}int main(int argc, char **argv){ int i, n; int a, b; scanf("%d", &n); for(i = 1; i < 阅读全文
posted @ 2011-08-21 16:58 zqynux 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 嗯,我练习了下二叉堆,代码写得挺长的,其实题目比较简单,就是贪心就行…… 嗯,上代码吧:#include <math.h>#include <stdio.h>#include <stdlib.h>#define left(i) (((i) << 1) + 1)#define right(i) (((i) << 1) + 2)#define parent(i) (((i) - 1) >> 1)struct node{ int x, y, v;}heap[400];int end;int n, m;void insert(in 阅读全文
posted @ 2011-08-20 15:55 zqynux 阅读(473) 评论(0) 推荐(0) 编辑
摘要: 怎么说呢,都说是全排列,但是我不会(等会儿看看),康拓排序我觉得用不了,因为太大了,long long都装不下,但是m的范围又小,所以可以直接枚举,代码如下:#include <stdio.h>#include <stdlib.h>int num[10000];int used[10001];int m, n;int t;void output(void){ int i; for(i = 0; i < n; i++){ if(i != 0){ printf(" "); } printf("%d", num[i]); } pr 阅读全文
posted @ 2011-08-19 21:15 zqynux 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 看到一个很好的结题报告,转一下:http://zhurui250.blog.163.com/blog/static/13727052020115273939197/【分析】数学推论题,我列一下站数 1 2 3 4 5 6 …… N上车人数 A F A+F A+2F 2A+3F 3A+5F …… 0下车人数 0 F F A+F A+2F 2A+3F …… M总人数 A A 2A 2A+F 3A+2F 4A+4F …… 0代码:#include <stdio.h>#include <stdlib.h>struct post{ int a, x;}s1[21], s2[21] 阅读全文
posted @ 2011-08-19 15:50 zqynux 阅读(754) 评论(0) 推荐(0) 编辑
摘要: 虽说是普及组,还是不好处理啊!想了好久,最后决定使用一个栈来维护所有的枚举,总的来说我这里算是用了两个栈(因为BFS本身就能算一个栈),这个题目真的有挑战性啊,算法没什么,但是规律方面的东西好重要饿。。。。 不说了,代码:#include <stdio.h>#include <stdlib.h>int flag = 0;int stack[100000];int top;void push(int k){ stack[top++] = k;}int pop(void){ return stack[--top];}void output(int k){ int i, j; 阅读全文
posted @ 2011-08-19 10:41 zqynux 阅读(1261) 评论(0) 推荐(0) 编辑
摘要: 我直接模拟的,第i个数字必定大于或等于第i-1个数字,我是按照这种思想模拟的,那么每种情况就只会考虑一次,然后需要一个重大剪枝: 当i=k-1的时候,就不去枚举了,直接得到答案,用n-sum,我还有一个小剪枝,因为我的第i个数一定大于或等于第i-1个数,那么如果第i个数加到第k个数就大于n的话,就没必要继续枚举了。 2011年08月29日: 刚刚发现,上次的代码有问题,数据太弱,所以过了,但是2 15 151,2 151 15的答案不一样,思索了好久,最后想出了正确的算法。 就是枚举两个字符串,如果相同就继续枚举,不同就继续枚举。。。。。(没听懂的看下面第二段代码,第一段只... 阅读全文
posted @ 2011-08-17 23:43 zqynux 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 裸搜索,然后处理下范围就行,代码如下:#include <stdio.h>#include <string.h>#include <stdlib.h>char middle[9], last[9];void srch(int m_s, int m_e, int l_s, int l_e){ int i; for(i = m_s; i <= m_e; i++){ if(middle[i] == last[l_e]){ break; } } printf("%c", last[l_e]); if(m_s != i){ srch(m_s, 阅读全文
posted @ 2011-08-17 17:22 zqynux 阅读(635) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 14 下一页