pku(1032)Parliament

贴道值得研究的题吧,虽然有人给出了解法,也总结出很多规律,可还是没有看到很好的证明 大意是把整数N分成不相等的任意个整数,使这些数乘积最大 有人总结了一些规律: 1.1<a1if a1=1, then a1(=1), a[t] together could be replaced by a[t]+1.reason: a[t]+1>a[t]*1 ----------------------------------------------------------------------------------------2.to all i, 1<=a[i+1]-a[i]...
acm | 2008-03-31 13:47 | 阅读 3719 次 | 评论 0 条

pku(2361)Tic Tac Toe

给提示 XXX XXX OOO XOO OO. X.X XOO O. . X.. yes no yes 就这么点要注意的: #include <iostream>char winner[9];char toe[3][3];int X,O;int legal;using namespace std;bool islegall(){ legal=0; if((X!=O+1)&amp;&amp;(X!=O)...
acm | 2008-03-29 10:39 | 阅读 1779 次 | 评论 0 条

面向对象c++——回文数

用面向对象写的回文数: 请大家指教: #include <iostream>#include <vector>using namespace std;class Panlindrome{ private: vector < char > t; int len; public: void Init_panlindrome() { char temp; this->len=0; while(cin >>temp&amp;&amp;temp!='@') { this->t.push_back(temp); this->len++; ...
数据结构 | 2008-03-27 20:02 | 阅读 3832 次 | 评论 3 条

pku(2406)Power Strings

用到了KMP的一些思想,主要就是求next[]函数 Problem: 2406 User: keloy Memory: 28648K Time: 282MS Language: C++ Result: Accepted Source Code #include <iostream> #include <string> using namespace std; string t; int Getnext() { int n=t.size(); int *next=new int[n+1]; int i=...
acm | 2008-03-27 17:08 | 阅读 2503 次 | 评论 1 条

pku(1328) Radar Installation

主要的思想是贪心, 用d做半径,小岛的点做圆心,圆和x轴上相交得到的区间就是可以包含这个小岛的radar,可以存在的位子。 排序,找到最多重叠点或区间,得到答案。 数据里头很变态,有d为负的情况。 在qsort的时候要注意因为用的是浮点数。 我是在wa了很多次之后终于过了…… #include <iostream>#include<math.h>#include<algorithm>using namespace std; typedef struct sea{ int x; int y;} Sea;typedef struct Radar{ ...
acm | 2008-03-25 23:24 | 阅读 4849 次 | 评论 0 条

pku(1157)LITTLE SHOP OF FLOWERS

动态规划: 不要想当然的以为最小值就是0,(o(∩_∩)o...)我就是这么wa了一次。 代码: #include <iostream>using namespace std;long sum[101]={0};long tempsum[101]={0};long bunch[101][101]={0};long max(int i, int j)//求最大值{ long temp=-2147483648; for(int s=i;s<=j;s++) { if(sum[s]>temp) temp=sum[s]; } return temp;}void...
acm | 2008-03-14 13:49 | 阅读 2317 次 | 评论 0 条

自己的第一个项目

前几天acm队教练说有项目问我做不做,我说好啊…… 很哀怨的事情就发生了………… 我拿到计划书之后才知道,我上当了。做的是一个软件外包的活,结果我就拿到了代码,其他什么东西都没拿到,甚至连接口说明都没有。接下来的几天真实哀怨了哦………… 不过还好今天很哀怨,已经把最哀怨的部分完成了……
杂谈 | 2008-03-12 19:46 | 阅读 2347 次 | 评论 2 条

pku(1061) 青蛙的约会

程序代码来自redcastle,我看了很多的关于一元同余方程的解释,都不是很名白,今天在redcastle的博客上看到了他的解释恍然大悟,终于把1061给AC了,http://hi.baidu.com/redcastle/blog/item/e6dc30d3a5574d023af3cfe0.html是代码, http://hi.baidu.com/redcastle/blog/item/934b232dbc40d336349bf7e4.html关于一元同余方程的解释。 我还是把我代码写出来 #include <iostream>using namespace...
acm | 2008-03-04 22:50 | 阅读 5449 次 | 评论 0 条
浏览255643次