HDU 2134 Cuts the cake】的更多相关文章

http://acm.hdu.edu.cn/showproblem.php?pid=2134 Problem Description Ice cream took a bronze medal in the Beijing match. Liu sir is very very happy. So he buys a cake for them. kiki is a child who likes eating, so the task of cuting cake was given to k…
pid=4454" target="_blank" style="">题目链接:hdu 4454 Stealing a Cake 题目大意:给定一个起始点s,一个圆形.一个矩形.如今从起点開始,移动到圆形再移动到矩形.求最短距离. 解题思路:在圆周上三分就可以.即对角度[0,2*pi]三分.计算点和矩形的距离能够选点和矩形四条边的距离最短值. #include <cstdio> #include <cstring> #incl…
King's Cake 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5640 Description It is the king's birthday before the military parade . The ministers prepared a rectangle cake of size n×m(1≤n,m≤10000) . The king plans to cut the cake himself. But he has…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 263    Accepted Submission(s): 113 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
King's Cake Problem Description It is the king's birthday before the military parade . The ministers prepared a rectangle cake of size n×m(1≤n,m≤10000) . The king plans to cut the cake himself. But he has a strange habit of cutting cakes. Each time,…
King's Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 736    Accepted Submission(s): 539 Problem Description It is the king's birthday before the military parade . The ministers prepared a…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:将n个草莓随机放在蛋糕上,草莓被看做是点,然后将蛋糕平均切成m份,求所有草莓在同一块蛋糕上的概率 Sample Input 2 3 3 3 4   Sample Output 1/3 4/27 分析:计算出这个概率公式为:n/(mn-1),m.n最大为20,mn超出了64位,用到大数,用java容易写出 代码如下: import java.math.BigInteger; impor…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率. 算法思路:n个草莓在圆形上有一个最左边的,为了好理解,先把假设草莓有1-n的不同编号.  现在从n个草莓中选出一个编号A的放在最左边(这个最左边可以随便放),得到C(n,1)*1.然后把其余的n-1草莓不分先后的放在A的右边角大小为(360)/m的扇形区域内就可以了. 所以概率为 n/(m^(n-…
Problem Description   It is the king's birthday before the military parade . The ministers prepared a rectangle cake of size n×m(1≤n,m≤10000) . The king plans to cut the cake himself. But he has a strange habit of cutting cakes. Each time, he will cu…
Stealing a Cake Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1164    Accepted Submission(s): 320 Problem Description There is a big round cake on the ground. A small ant plans to steal a sma…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762 题意:有个蛋糕,切成m块,将n个草莓放在上面,问所有的草莓放在同一块蛋糕上面的概率是多少.2 < M, N <= 20 分析:概率题,公式题.可惜我数学太差,想了好久都想不出来,看了题解还是不太明白怎么算的. 最后的概率公式为:n / (m^(n-1)),然后用高精度就可以了,最后的结果要约分,可以在计算的过程中求gcd(n,m),然后分子分母同除以该数就可以了. 这里有两个方法可以推出来.…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 300    Accepted Submission(s): 135 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1657    Accepted Submission(s): 806 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake tog…
Cut the cake Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1250    Accepted Submission(s): 489 Problem Description: Mark bought a huge cake, because his friend ray_sun’s birthday is coming. Ma…
题目链接 去年杭州现场赛的神题..枚举角度..精度也不用注意.. #include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <cmath> #include <algorithm> using namespace std; #define eps 1e-8 #define PI 3.1415926 double xl,xr,y…
题意: 给一个点,一个圆,一个矩形, 求一条折线,从点出发,到圆,再到矩形的最短距离. 解法: 因为答案要求输出两位小数即可,精确度要求不是很高,于是可以试着爆一发,暴力角度得到圆上的点,然后求个距离,求点到矩形的距离就是求点到四边的距离然后求个最小值,然后总的取个最小值即可. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include &l…
猜公式: ans=n/m^(n-1) #include<stdio.h> #include<string.h> struct BigNum { ]; int len; }; int gcd(int a,int b) { ) return a; return gcd(b,a%b); } BigNum mul(BigNum &a,int b) { BigNum c; int i,len; len=a.len; memset(c.num,,sizeof(c.num)); ) {…
很容易想到三分法求解,不过要分别在0-pi,pi-2pi进行三分. 另外也可以直接暴力枚举…… 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector> #define ll __int64 #define pi aco…
简单的计算几何: 可以把0-2*pi分成几千份,然后找出最小的: 也可以用三分: #include<cstdio> #include<cmath> #include<algorithm> #define pi acos(-1) #define eps 1e-6 using namespace std; struct node { double x,y; node(,):x(x),y(y){ } bool operator<(const node &t)co…
我比较快速的想到了三分,但是我是从0到2*pi区间进行三分,并且漏了一种点到边距离的情况,一直WA了好几次 后来画了下图才发现,0到2*pi区间内是有两个极值的,每个半圆存在一个极值 以下是代码 #include <cstdio> #include <cmath> #include <algorithm> #define pi acos(-1.0) using namespace std; typedef struct { double x; double y; }po…
给定一个起始点,一个矩形,一个圆,三者互不相交.求从起始点->圆->矩形的最短距离. 自己画一画就知道距离和会是凹函数,不过不是一个凹函数.按与水平向量夹角为圆心角求圆上某点坐标,[0, PI] , [PI, 2*pi]两个区间的点会有两个凹函数.所以要做两次三分才行. #include<algorithm> #include<iostream> #include<fstream> #include<sstream> #include<cs…
题意:已知起点.圆.矩形,要求计算从起点开始,经过圆(和圆上任一点接触即可),到达矩形的路径的最短距离.(可以穿过园). 分析:没什么好的方法,凭感觉圆上的每个点对应最短距离,应该是一个凸函数,用三分来解.不过应该是分成两部分,用两次三分来解.具体原因不明,通过实验只能得出三分必须是针对一个凸函数,很明显,从0~2*pi不是一个凸函数,但同理,0~pi,pi~2*pi也不一定是个凸函数.个人认为,网络上流传的[0,pi][pi,2*pi]这种分法,并不存在合理性.继续思考= =  另外,直接暴力…
题意: 给定长方形,每次从中切去一个最大的正方形,问最终可以得到多少正方形. 分析: 过程类似求gcd,每次减去最小的边即可. 代码: #include <cstdio> #include<algorithm> #include<iostream> using namespace std; int main (void) { int T;cin>>T; int n, m; while(T--){ cin>>n>>m; int cnt…
给定一个由n个整点构成的凸多边形,求从n个点里任意选不少于3个点组成的所有凸多边形的面积之和,显然整点构成的多边形面积一定是0.5的整数倍,所以题目需要你算出答案的2倍 mod1000000007的值. 1.凸多边形里选出点组成的还是凸多边形. 2.三个点A,B,C构成的三角形,设从原点到他们的向量为fA,fB,fC,那么三角形面积的2倍就是fA×fB+fB×fC+fC×fA. 3.同理k个点(对应向量按逆时针排序为f1,f2,...,fk)构成的多边形面积的倍等于  对于两个在原多边形上的点i…
题意:给你一个n*m的的矩形框 现在又k条射线 问这个矩形框会被分为多少个区域 思路:之前的想法是枚举边界然后线段树扫一遍计算一下矩形个数 复杂度果断不行 后面发现其实答案就是交点数+1 然后就用线段树上下扫两边 #include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const int N = 1e5+7; const int inf = 0x3f3f3f3f; typedef long long…
Cuts the cake Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2202    Accepted Submission(s): 1354 Problem Description Ice cream took a bronze medal in the Beijing match. Liu sir is very very h…
Scanner cin = new Scanner(new BufferedInputStream(System.in)); 这样定义Scanner类的对象读入数据可能会快一些! 参考这个博客继续补充内容:http://blog.csdn.net/lmyclever/article/details/6408980 1. 单元变量常用大数操作: import java.util.Scanner; import java.math.*; public class Main{ public stati…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5355 题意:给你n个尺寸大小分别为1,2,3,…,n的蛋糕,要求你分成m份,要求每份中所有蛋糕的大小之和均相同,如果有解,输出“YES”,并给出每份的蛋糕数及其尺寸大小,否则输出“NO” 例如n=5,m=3,即大小尺寸分别为1,2,3,4,5的5个蛋糕,要求分成三份,那么解可以是第一份一个蛋糕,大小为5:第二份两个蛋糕,大小为1.4:第三份两个蛋糕,大小为2.3.这样每份大小之和均为5,满足题目要求…
题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1632    Accepted Submission(s): 273 Special Judge Problem Description There are m…
HDU 5355 Cake 更新后的代码: 今天又一次做这道题的时候想了非常多种思路 最后最终想出了自觉得完美的思路,结果却超时 真的是感觉自己没救了 最后加了记忆化搜索,AC了 好了先说下思路吧.不知道大家住没注意m<=10 我们能够把大部分的数据写成成对的形式比如n=27 m=6的这组数据 第1份  27  16 第2份  26  17 第3份  25  18 第4份  24  19 第5份  23  20 第6份  22  21 剩下1~15搜索出6等份分给全部人 这样成对出现的数蛇形数我…