上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页

2013杭电 warm 2, hdu 4717 The Moving Points 三分

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4717第一次写三分,这个解法是学解题报告的,感谢原作者。首先对每对点对,他们的距离关于时间t是二次函数,现在就是求c[n][2] 个二次函数,每个点取最大值构成的函数的极值。 由于每个子函数都是先减后增,或者对称轴小于0,直接单增,他们的max一定也保持着这个性质 (具体证明和n个下凸函数max还是下凸函数很像?)然后取100次精度就够了代码:#include#include#includeusing namespace std;int x[300],y[300],vx[300],vy[300];i 阅读全文
posted @ 2013-09-23 23:30 814jingqi的ACM 阅读(109) 评论(0) 推荐(0) 编辑

poj 3258 River Hopscotch 二分答案

摘要: 题目地址:http://poj.org/problem?id=3258题目思路: 首先,如果只减少一部,那么一定要干掉最短的那段距离(一旦不消灭,最小的还是它,并没有达到使最小值取最大的理想情况)。 但是如果有很多边取到最小,具体去除哪一个点就有点麻烦了。如果两个最小距离连着,去除公共点最好。 如果没有连着,四个点分别考虑紧邻的,取最小的。 如果多于两条线段取最小随便去,如果仅有一条取最小仍是去紧邻较小的点。 很麻烦就是了。基于这样的思想,每次去掉一个顶点后,再取出最小边,同样处理(借助优先权队列) 。不知这样的贪心是不是对的...有一个二分答案的做法,现学的.一般的二分查找是 while(. 阅读全文
posted @ 2013-09-22 02:20 814jingqi的ACM 阅读(315) 评论(0) 推荐(0) 编辑

2013杭电warm up1 hdu 4712 Hamming Distance

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4712首先,算汉明距离就是二进制异或以后的1的个数,统计1的个数用x&=x-1很快很神奇。用if(x&1) {count++; x>>=1;} 在位数比较多的时候会慢一些。然后就是看题解学到的神奇的“随机”! 来取到“任意的两个” 1w次wa,但是10w次就不会,20组testcase ,不会超时;真的ac了,很神奇代码:#include#include#include#include#includeusing namespace std;int a[100005];in 阅读全文
posted @ 2013-09-21 20:28 814jingqi的ACM 阅读(139) 评论(0) 推荐(0) 编辑

zoj 3432 Find the Lost Sock (ZOJ Monthly, November 2010)

摘要: 题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3432题目思路: 其实就是找那个只出现了1次的字符串。 但是如果用数组或者map记录出现的次数,10w的数量会导致超时,学到一种神奇的方式--直接用异或处理先看代码:#include#include#includeusing namespace std;string s;char sock[9];char ans[9];int main(){ int n; cin>>n; while(cin>>n) { getchar(); n=... 阅读全文
posted @ 2013-09-20 23:21 814jingqi的ACM 阅读(115) 评论(0) 推荐(0) 编辑

zoj 4113 Cube Simulation ( ZOJ Monthly, November 2010 )

摘要: 题目地址:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4113思路:这个就是三维数组的地址和下标之间的对应。 然后涉及到一定的变换 ,我们有一个p【a】 记录在若干次对换之后实际对应的是哪个数。 同时,为了能用find函数找回坐标,我们还要记录反函数(写作pp【a】)然后这个value超过的xyz是不要输出的。代码:#include#include#include#includeusing namespace std;int p[1010];int q[1010];int r[1010];int pp[1010];int 阅读全文
posted @ 2013-09-20 21:58 814jingqi的ACM 阅读(112) 评论(0) 推荐(0) 编辑

2013杭电warm up1 Rotation Lock Puzzle

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4708首先来学习一个ac的代码:作者http://blog.csdn.net/xingyeyongheng#include#include#include#include#include#include#include#include#define INF 99999999using namespace std;const int MAX=10;int s[MAX][MAX];int main(){ int n; while(scanf("%d",&n),n){ for( 阅读全文
posted @ 2013-09-20 00:13 814jingqi的ACM 阅读(111) 评论(0) 推荐(0) 编辑

2013杭电warm_up1 1010 Difference Between Primes

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4715首先打素数表,然后分三类 x=0,>0, #include#includeusing namespace std;#define N 10000000bool p[N+1];void pre(){ int d=sqrt(N); for(int i=2;i>n; for(int i=0;i0) { for(start=2;start<=10000000-x;start++) { if(!p[st... 阅读全文
posted @ 2013-09-19 16:45 814jingqi的ACM 阅读(119) 评论(0) 推荐(0) 编辑

2013 Multi-University Training Contest 3 (g) The Unsolvable Problem

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4627[a,b]=ab/(a,b) a,b和一定时,越接近乘积越大,在接近的同时,尽量保持公因子最少。 如果n为2*k+1 那么 取a=2k,b=2k+1 最佳。 如果n为偶数=2k,就要进一步分k的奇偶性了。 n=4k 时 显然2k+2k会很小 2k-1,2k+1 就满足了 (2k-1,2k+1)=(2,2k+1)=1 。 如果n=4k+2 ,逐一实验2k+1,2k+1。 2k 2k+2. 2k-1,2k+3 。发现2k-1,2k+3是最佳的,而且他们已经互素了,再增大差距结果不会优于这组。 .. 阅读全文
posted @ 2013-09-19 15:00 814jingqi的ACM 阅读(118) 评论(0) 推荐(0) 编辑

2013杭电warm up1 1002 Pet 求树结点的高度(bfs,dfs两种求法)

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4707题目给出一颗树,要求求出深度大于D的结点的个数。有两种方法,改写dfs,给一个参数放层数(额,其实这里不需要转化为有根树,多余了)代码:#include#include#include#includeusing namespace std;#define maxn 100005vector G[maxn];int p[maxn];int lev[maxn];//vector leaf;void dfs(int u,int fa,int level) // 无根树转化为有根树{ in... 阅读全文
posted @ 2013-09-18 00:17 814jingqi的ACM 阅读(186) 评论(0) 推荐(0) 编辑

hdu 3789 奥运排序问题 模拟

摘要: 题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3789首先 题目要求只对m个国家排序,然后输出的顺序是给的国家编号的顺序~~!! 不一定是升序` wa了n次在这里然后用sort死做代码:#include#include#include#includeusing namespace std;struct nation{ long double gold; long double all; long double area; int id; int rate1; int rate2; int rat... 阅读全文
posted @ 2013-09-17 14:56 814jingqi的ACM 阅读(220) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 11 12 ··· 17 下一页