上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 24 下一页
摘要: 1 /* 2 此题居然可以用二分来做,首先二分出答案。 3 4 然后判断答案是否合理,问题在于给出一个答案的时候,如何判断合理性 5 6 分析:假如X是答案,既然是答案,那么就把它当成最终的答案,这个可以理解吧。现在对于N个花费,从第一天开始算起 7 算连续几天的和直到大于X为止,然后在从这个截止的天开始从新算,如此类推,因为是答案所以可以这么计算,最后看能算出几个月来,如果 8 在要求的月数之内,那么就符合要求。最后找出最大的答案就是了 9 10 好题 11 */ 12 13 // include file 14 #include <cstdio> 15 #include < 阅读全文
posted @ 2011-03-10 09:42 AC2012 阅读(604) 评论(0) 推荐(0) 编辑
摘要: 1 // include file 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <cctype> 7 #include <ctime> 8 9 #include <iostream> 10 #include <sstream> 11 #include <fstream> 12 #include <iomanip> 13 #include 阅读全文
posted @ 2011-03-09 21:04 AC2012 阅读(249) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 堆栈练习好题 3 4 也可线段树过 5 */ 6 7 // include file 8 #include <cstdio> 9 #include <cstdlib> 10 #include <cstring> 11 #include <cmath> 12 #include <cctype> 13 #include <ctime> 14 15 #include <iostream> 16 #include <sstream> 17 #include <fstream> 18 阅读全文
posted @ 2011-03-09 20:01 AC2012 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 数学题,矩阵相乘 3 4 关于二维矩阵在递归上的分析搞的我头大了,错了,也不知道哪错了。~ 5 6 S = A + A^2 + A^3 + A^4 + A^5 + ... 7 8 B = A I A I 9 0 I 0 I 10 11 B^2 = A^2 A+I A I 12 0 I 0 I 13 14 B^3 = A^3 A^2+A+I A I 15 0 I 0 I 16 17 B^4 = A^4 A^3+A^2+A^1+I 18 0 I 19 20 21 */ 22 23 // include file 24 #include <cstdio> 25 #inclu 阅读全文
posted @ 2011-03-09 18:39 AC2012 阅读(878) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 数学计算题,居然一次通过,RP那是大大的提高 3 */ 4 // include file 5 #include <cstdio> 6 #include <cstdlib> 7 #include <cstring> 8 #include <cmath> 9 #include <cctype> 10 #include <ctime> 11 12 #include <iostream> 13 #include <sstream> 14 #include <fstream> 15 阅读全文
posted @ 2011-03-09 11:00 AC2012 阅读(296) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 好题,把哈夫曼编码的思想融汇进来 3 初看好像是贪心,结果是错的。后来举个例子,发现,贪心果然不行。 4 5 可把所有的木板的长度看成是一课二叉树的叶子节点。为什么要二叉树呢?因为根据题意,每个木板切开之后会形成左右两个木板 6 可以模型化为二叉树。最后的问题可以归结为:所有叶子节点的权乘以路径长度的和,也就是说带权路径长度的和的最小值了 7 这其实就是求最优二叉树(哈弗曼树) 8 9 带权路径长度综合 10 weighted path length of tree 11 哈夫曼编码 12 */ 13 14 // include file 15 #include <cstd 阅读全文
posted @ 2011-03-09 10:23 AC2012 阅读(331) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 简单题,题意是求每个人赢了多少次,赢的次数最多的那个人是代表 3 */ 4 5 #include <cstdio> 6 #include <cstdlib> 7 int n,a,ans,anss,sum; 8 int main() 9 {10 scanf("%d",&n);11 anss = 0;12 for(int i=0;i<n;i++)13 {14 sum = 0;15 for(int j=0;j<n;j++)16 {17 scanf("%d",&a);18 if(a==3) sum 阅读全文
posted @ 2011-03-08 21:11 AC2012 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 数学题,虽然简单,但是还要要仔细思考下的 3 4 题目意思是说,对于N个硬币,不管初试的正反情况如何,都可以通过K次的调整达到全反全正的情况,必须是K次 5 对于所有的情况都是K次 6 7 现在假如N是奇数 8 9 那么最大可能的调整次数是N-1,而N-1是偶数,N是奇数个硬币,不管怎么组合,最后必然是奇数个正和偶数个反或者奇数个反偶数个正,N-1次(偶数)的反转对于偶数永远是成立的10 所以N-1对于N是奇数的情况,永远都可以调整过来11 12 如果N是偶数,那么最大的调整是N-1(奇数),N的组合可以是偶偶,或者奇奇,N-1(奇数)对于偶偶永远都不成立,所以对于N是偶数的情. 阅读全文
posted @ 2011-03-08 20:53 AC2012 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 1 /* 2 数学题 3 4 对于一个2^N的环,采用 5 从0开始,隔0,1,2,3,4,5,6....的方式去涂色,2^N步之后,刚好每个被涂色一次。如果不是2^N形式的个数, 6 会有些位置永远都无法到达 7 */ 8 #include <cstdio> 9 int main()10 {11 int N;12 while(scanf("%d",&N)!=-1)13 {14 if(N&(N-1))15 puts("NO");16 else17 puts("YES");18 }19 return 0;20 阅读全文
posted @ 2011-03-08 19:31 AC2012 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 1 // include file 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <cctype> 7 #include <ctime> 8 9 #include <iostream> 10 #include <sstream> 11 #include <fstream> 12 #include <iomanip> 13 #include 阅读全文
posted @ 2011-03-08 18:22 AC2012 阅读(327) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 24 下一页