摘要: 思路:首先,暴力会TLE,所以要把4个数分成2个和2个(关于这一点请阅读《挑战程序设计竞赛》)。注意到a*x1^2+b*x2^2的范围大小为2000000,我们不妨遍历前两个数,计算并记录在一个数组hash[]后,再遍历后两个数,并在hash[]中直接查找,这样复杂度就为O(n^2)(n=10... 阅读全文
posted @ 2015-12-20 16:21 StevenLuke 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include #include #define N 1000001using namespace std;bool cmp(const int& a, const int& b) { return a > b;}int main() { int n, m, i; int d[N]; whi... 阅读全文
posted @ 2015-12-20 16:09 StevenLuke 阅读(172) 评论(0) 推荐(0) 编辑
摘要: //据说使用线段树的 #include #include #define N 101int i, j, ans, buf[N][N];void print() { ans = 0; for(i=0; ibx) { tmp = ax; ax = bx; bx = tmp; } if... 阅读全文
posted @ 2015-12-20 14:52 StevenLuke 阅读(94) 评论(0) 推荐(0) 编辑