10 2013 档案

摘要:import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { BigInteger ans,Zero; Zero = BigInteger.ZERO; ans = BigInteger.ZERO; Scanner cin = new Scanner(System.in); while(cin.hasNextBig... 阅读全文
posted @ 2013-10-31 20:17 等待最好的两个人 阅读(194) 评论(0) 推荐(0)
摘要:题目链接:http://codeforces.com/contest/358/problem/D#include#include#include#includeusing namespace std;const int maxn = 3005;int a[maxn],b[maxn],c[maxn];int dp1[maxn],dp2[maxn];int n;int main(){ //freopen("E:\\acm\\input.txt","r",stdin); cin>>n; for(int i=1; i>a[i]; for(int 阅读全文
posted @ 2013-10-31 17:04 等待最好的两个人 阅读(210) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4122代码:#include#include#include#include#include#includeusing namespace std;const int maxn = 100500;struct Node{ int id,val;};int order[2555];long long R[2555];int S,T,N,M;struct Myqueue{ Node Q[maxn]; int head,tail; void init() { h... 阅读全文
posted @ 2013-10-24 22:40 等待最好的两个人 阅读(182) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=2503代码:#include#include#include#includeusing namespace std;const int maxn = 100050;const int HASH = 1000003;int head[HASH],next[maxn];char s1[maxn][15],s2[maxn][15];int n;int hash(char *s){ int ret = 0; int seed = 131; while(*s) { ret = ret * seed + ... 阅读全文
posted @ 2013-10-11 18:48 等待最好的两个人 阅读(241) 评论(0) 推荐(0)
摘要:题目链接: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 等待最好的两个人 阅读(270) 评论(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 等待最好的两个人 阅读(176) 评论(0) 推荐(0)
摘要:博客链接:http://blog.csdn.net/bruce0532/article/details/8126150 阅读全文
posted @ 2013-10-07 22:56 等待最好的两个人 阅读(97) 评论(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 等待最好的两个人 阅读(184) 评论(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 等待最好的两个人 阅读(309) 评论(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 等待最好的两个人 阅读(159) 评论(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 等待最好的两个人 阅读(112) 评论(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 等待最好的两个人 阅读(166) 评论(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 等待最好的两个人 阅读(291) 评论(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 等待最好的两个人 阅读(431) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4474(a*10+b)%c = ((a%c)*10+b%c)%c;然后从高位开始枚举能填的数字填充,只是注意最高位(第一位)不能为0。代码:#include#include#include#include#include#includeusing namespace std;struct Node{ string s; int mod; Node(string s="",int mod=0): s(s),mod(mod) {}};bool can[15];bool vis[100 阅读全文
posted @ 2013-10-05 18:57 等待最好的两个人 阅读(200) 评论(0) 推荐(0)
摘要:题目链接:http://codeforces.com/problemset/problem/348/A代码:#include#include#include#includeusing namespace std;int main(){ //freopen("E:\\acm\\input.txt","r",stdin); int n; scanf("%d",&n); long long L,R; L = R = 0; for(int i=1; i<=n; i++) { long long a; scanf("%I 阅读全文
posted @ 2013-10-03 12:56 等待最好的两个人 阅读(191) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4750代码:#include#include#include#includeusing namespace std;const int maxn = 10005;const int maxm = 500500;struct Edge{ int u,v,w; Edge(int u=0,int v=0,int w=0): u(u), v(v), w(w) {} bool operator >n>>m) { for(int i=0; i<n; i++) ... 阅读全文
posted @ 2013-10-01 22:45 等待最好的两个人 阅读(198) 评论(0) 推荐(0)
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4882代码:#include#include#include#include#includeusing namespace std;const int maxn = 200005;struct Edge{ int u,v,w; Edge(int u=0,int v=0,int w=0): u(u), v(v), w(w) {} bool operator rhs.w; }}edges[maxn];int counts[maxn];int p... 阅读全文
posted @ 2013-10-01 20:37 等待最好的两个人 阅读(154) 评论(0) 推荐(0)
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4879代码:#include#include#include#include#includeusing namespace std;const int maxn = 550;struct Two_Sat{ int n; vector G[maxn*2]; bool mark[maxn*2]; int s[maxn*2],cnt; void init(int n) { this->n = n; memse... 阅读全文
posted @ 2013-10-01 12:06 等待最好的两个人 阅读(185) 评论(0) 推荐(0)
摘要:题目链接:http://poj.org/problem?id=3678代码:#include#include#include#include#includeusing namespace std;const int maxn = 1050;struct Two_Sat{ int n; vector G[maxn*2]; bool mark[maxn*2]; int s[maxn*2],cnt; void init(int n) { this->n = n; memset(mark,0,sizeof(mark)); f... 阅读全文
posted @ 2013-10-01 10:42 等待最好的两个人 阅读(186) 评论(0) 推荐(0)