上一页 1 2 3 4 5 6 7 ··· 18 下一页
摘要: 题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=970第一次正式用hash表。代码:#include#include#include#includeusing namespace std;const int maxn = 25500;const int HASH = 1000003;char s[maxn][20];int head[HASH],next[maxn];int dp[maxn];int n;char tem 阅读全文
posted @ 2013-10-11 16:22 等待最好的两个人 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4091/** 这题的一种思路就是枚举了:基于这样一个事实:求出lcm = lcm(s1,s2), num1 = lcm/s1, num2 = lcm/s2; 则价值与体积比小的那个宝藏个数一定大于lcm/size;这个用反证法就可证明。然后就是只需要枚举N%lcm + lcm这个体积的最有分配。 */#include#include#include#includeusing namespace std;long long N,s1,v1,s2,v2;long long ans;long long . 阅读全文
posted @ 2013-10-10 22:15 等待最好的两个人 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 博客链接:http://blog.csdn.net/bruce0532/article/details/8126150 阅读全文
posted @ 2013-10-07 22:56 等待最好的两个人 阅读(90) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4432代码:#include#include#include#includeusing namespace std;int sum;int n,k;int tranfer(int num){ int ret = 0; while(num > 0) { int a = num%k; num = num/k; ret += a*a; } return ret;}int main(){ // freopen("E:\\acm\\i... 阅读全文
posted @ 2013-10-06 19:14 等待最好的两个人 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4433题目大意:给你一连串密码,(密码是0-》9循环转动),求最少的步骤到达目标数码。算法思路:这个题一看就觉得要用dp思想,就是方程不好想,抓住题目给的可以连续拨动1-3密码,我的dp[i][j][k]表示第i个数字为j,第i+1个数字为k,i及以后到达目标所有的最少步骤。然后记忆化搜。代码:#include#include#include#includeusing namespace std;int dp[1050][10][10];char in[1050],out[1050];int len 阅读全文
posted @ 2013-10-06 19:05 等待最好的两个人 阅读(306) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4465参考博客:http://www.cnblogs.com/goagain/archive/2012/11/20/2778633.html看他的分析足够了下面的代码也是他写的,觉得优美就贴下来:#include#include#include#include#includeusing namespace std;double solve(int n,double p){ double ret = p*n; double last = 1; for(int m=n+1; m>n>> 阅读全文
posted @ 2013-10-05 21:16 等待最好的两个人 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4472代码:#include #include #include #include #include #include #include #include using namespace std;const int maxn = 1055;const int maxe = 1e6+100;const int INF = 0x3f3f3f3f;const int mod = 1e9 +7;int main(){ long long dp[maxn]; int n; dp[1] = ... 阅读全文
posted @ 2013-10-05 19:35 等待最好的两个人 阅读(101) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1106算法思路:由于圆心和半径都确定,又是180度,这里枚举过一点的直径,求出这个直径的一个在圆上的端点,就可以用叉积的大于,等于,小于0判断点在直径上,左,右。 这里要记录直径两边的加直径上的点的个数,去最大的。代码:#include#include#include#include#include#includeusing namespace std;const double eps = 1e-8;const double PI = acos(-1.0);const double INF = 1000000000000000.0 阅读全文
posted @ 2013-10-05 19:25 等待最好的两个人 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://poj.org/problem?id=1329输出很蛋疼,要考虑系数为0,输出也不同#include#include#include#include#include#includeusing namespace std;const double eps = 1e-8;const double PI = acos(-1.0);const double INF = 1000000000000000.000;struct Point{ double x,y; Point(double x=0, double y=0) : x(x),y(y) { } //构造函... 阅读全文
posted @ 2013-10-05 19:19 等待最好的两个人 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 题目链接:http://codeforces.com/contest/351/problem/A算法思路:2n个整数,一半向上取整,一半向下。我们设2n个整数的小数部分和为sum.ans = |A - B|;sum = A +(n-b)-B;所以ans = |sum - (n-b)|; 只有b未知,只需要枚举一下b就得到答案。#include#include#include#include#includeusing namespace std;const int maxn = 2005;const double eps = 1e-12;int dcmp(double x){ if(fab... 阅读全文
posted @ 2013-10-05 19:11 等待最好的两个人 阅读(419) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 18 下一页