目录: B - Fraction D - Triangle F - Harmonic Value Description H - Sequence I I - Sequence II B题:HDU 5912 - Fraction - [递归] 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5912 Problem DescriptionMr. Frog recently studied how to add two fractions up, an…
E Find the median 题意:每次往序列中增加连续的[l,r]的数,每加入一次就询问当前序列的中位数. 解法:此题没有要求在线,那么直接离线+线段树+二分就可以了.求出每个端点之后排序得到数组b,线段树每个叶子结点i存储的是区间[ b[i-1]+1,b[i] ]的系数(即当前序列有多少个[ b[i-1]+1,b[i] ]).修改时顺便维护当前总的数个数sum,然后处理询问就是直接在线段树上二分就可以了. #include<bits/stdc++.h> #define lc o*2…
poj2114 Boatherds Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1195 Accepted: 387 Description Boatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers…
A B C #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #define TS printf("!!!\n") #define pb push_back #define inf 1e9 //std::ios::sync_with_stdio(false); using namespace std; //priority_queue<int,…
Harry Potter and J.K.Rowling http://acm.hdu.edu.cn/showproblem.php?pid=3982 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1094 Accepted Submission(s): 357 Problem Description In July 31st,…
#include <stdio.h> int main() { int i,j,k; printf("\n"); for(i=1;i<5;i++){ for(j=1;j<5;j++){ for (k=1;k<5;k++){ if (i!=k&&i!=j&&j!=k) printf("%d,%d,%d\n",i,j,k); } } } }…
有两个序列A和B,A=(a1,a2,...,ak),B=(b1,b2,...,bk),A和B都按升序排列.对于1<=i,j<=k,求k个最小的(ai+bj).要求算法尽量高效. int *min_k(int *A, int *B, int len1, int len2, int k) { if (A == NULL || B == NULL || k <= 0) return NULL; int i, j; int *tmp = new int[k]; i = len1; j = len…
B. Balanced Diet 思路:把每一块选C个产生的价值记录下来,然后从小到大枚举C. #include<bits/stdc++.h> using namespace std; ; typedef long long ll; vector<int> G[maxn]; int l[maxn], a[maxn], b[maxn]; ll dp[maxn]; bool cmp(int a, int b) { return a > b; } int main() { std:…
目录 Codeforces 1091 A.New Year and the Christmas Ornament B.New Year and the Treasure Geolocation C.New Year and the Sphere Transmission(思路) D.New Year and the Permutation Concatenation(思路 计数) E.New Year and the Acquaintance Estimation(Erdos–Gallai定理…
Problem - 3982 题意就是给出一个圆心在原点半径为R的圆形蛋糕,上面有一个cherry,对蛋糕切若干刀,最后要求求出有cherry的那块的面积占整个蛋糕的多少. 做法显而易见,就是一个半平面交,将有向直线的方向根据cherry的位置确定好,然后就进行半平面交,得到一个多边形. 再将多边形用之前几个代码的圆与多边形交,求出区域的大小,再除以整个蛋糕的面积即可. 注意,这样做的时候,精度是要用1e-6或者是1e-4,太高了反而过不了数据. ——written by Lyon…