题目题意:给n,求x;直接枚举肯定超时, 把给的式子变形, (y+x)(y-x) = n;令y-x =
b, y+x = a;枚举b, b 的范围肯定是sqrt(n), y = (a+b)/2; x = (a-b)/2;b越大, x越小, 所以倒着枚举b 1
#include 2 #include....
分类:
其他好文 时间:
2014-05-05 11:01:25
阅读次数:
244
try{ INIT_PLUG I_MongoDB* i = NEW(MongoDB);
/*【注】 若自定义错误消息的数组长度必需指定为MAX_ERROR_SIZE*/ //char errmsg[MAX_ERROR_SIZE]={0};//方式一
...
http://acm.hdu.edu.cn/showproblem.php?pid=1598
1 #include 2 #include 3 #include 4 #define maxn 2000 5 using namespace std; 6
const int inf=1<<30; 7...
分类:
其他好文 时间:
2014-05-05 10:53:38
阅读次数:
344
http://acm.hdu.edu.cn/showproblem.php?pid=1599floyd找最小环。 1 #include 2 #include 3
#include 4 #define maxn 200 5 using namespace std; 6 const int inf...
分类:
其他好文 时间:
2014-05-05 10:52:15
阅读次数:
315
$\bf命题2:$设$f\left( x \right) \in C\left( { -
\infty , + \infty } \right)$,令\[{f_n}\left( x \right) = \sum\limits_{k = 0}^{n -
1} {\frac{1}{n}} f\left(...
分类:
其他好文 时间:
2014-05-04 19:12:48
阅读次数:
361
$\bf命题1:$设正项级数$\sum\limits_{n = 1}^\infty
{{a_n}} $发散,且${s_n} = \sum\limits_{k = 1}^n {{a_k}} $,试讨论级数$\sum\limits_{n =
1}^\infty {\frac{{{a_n}}}{{{s_n...
分类:
其他好文 时间:
2014-05-04 19:03:33
阅读次数:
360
Escape
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 584 Accepted Submission(s): 117
Problem Description
R's girl friend D is on m...
分类:
其他好文 时间:
2014-05-04 18:38:40
阅读次数:
379
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1015
深搜简单题
代码如下:
#include
#include
#include
#include
using namespace std;
string a;
int t;
int v,w,x,y,z;
int vis[20];
int b[6];
int flag;
int cmp(int...
分类:
其他好文 时间:
2014-05-04 18:09:00
阅读次数:
352
题意:
给定n个物品 m元,k种商品
下面n行 tpye w v 表示物品的牌子,价格,价值(每个物品只有1件)
问:每个牌子至少买一件能获得的最大价值是多少
思路:分组背包
#include
#include
#include
#include
#include
using namespace std;
#define ll int
ll n, m, k;
l...
分类:
其他好文 时间:
2014-05-04 18:03:15
阅读次数:
248
题目:
输入一个已经按升序排序过的数组和一个数字,在数组中查找两个数,使得它们的和正好是输入的那个数字。要求时间复杂度是O(n)。如果有多对数字的和等于输入的数字,输出任意一对即可。
例如输入数组1、2、4、7、11、15和数字15。由于4+11=15,因此输出4和11。
思路:
最直接的做法是暴力法,两个for循环,时间复杂度为O(n*n),但是这样没有充分利用升序数组这一前提。我们假设数组为A,长度为len,给定的和为sum,最好的方法是先用数组的第一个数A[lo...
分类:
其他好文 时间:
2014-05-04 17:56:57
阅读次数:
596