上一页 1 ··· 132 133 134 135 136 137 138 139 140 ··· 182 下一页
摘要: 题意:给出ai(i=1~5),求a1 * x1^3+ a2 * x2^3+ a3 * x3^3+ a4 * x4^3+ a5 * x5^3=0在-50到50之间的x的解的个数分析:用map,二重循环枚举x1,x2计算结果在map中对应位++三重循环枚举x3,x4,x5计算结看map中对应的相反数的个数。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <map>usingnamespace std;int 阅读全文
posted @ 2011-06-09 22:08 undefined2024 阅读(822) 评论(0) 推荐(0)
摘要: 题意:有一个天平,两个臂上有钩子,给出所有钩子的位置,给出每个钩码的重量(各不相同),求必须使用所有钩码的前提下,有多少种平衡方法。分析:dp,f[i][j + 5000]表示用前i个砝码到达力矩j的方法数f[i + 1][j + hook[k] * weight[i]] += f[i][j];最终结果存储在f[n][5000]中。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>usingnamespace std;#define 阅读全文
posted @ 2011-06-09 18:36 undefined2024 阅读(784) 评论(0) 推荐(0)
摘要: 简单题,求使数列程先递增后递减的形式需要去掉的数字个数。当然也可以直接递减或者只递减不递增。用最长递增子序列的方法求,然后枚举两个起点的位置即可。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1005int n;double f[maxn];int len1[maxn], len2[maxn];int main(){// freopen("t.txt&qu 阅读全文
posted @ 2011-06-09 18:08 undefined2024 阅读(489) 评论(0) 推荐(0)
摘要: 题意:平面上的一些点,问有多少点的右上方没有点(即不存在x,y均比它大的点)。分析:本来想 用求逆序数的方法,后来上网发现了更简单的方法。按x从小到大,x相等按y从小到大排序后,从右到左,一旦遇到一个比之前见过的y都大的y,就把ans++;View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>usingnamespace std;#define maxn 50005struct Poin 阅读全文
posted @ 2011-06-09 10:58 undefined2024 阅读(248) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1006int n;int a[maxn], cnt, c[maxn];void input(){ scanf("%d", &n); for (int i = 0; i < n; i++) scanf("%d", &a[i]);}void MergeSo 阅读全文
posted @ 2011-06-08 18:08 undefined2024 阅读(199) 评论(0) 推荐(0)
上一页 1 ··· 132 133 134 135 136 137 138 139 140 ··· 182 下一页