Graveyard LA3708】的更多相关文章

白书第一章例题4 思维. 先固定一点不动,假设最后一共N个点,那么编号为0,1,...N-1, 0不动,原来的n个点分别占据i/n*N的位置(记为pos),移动到pos四舍五入的位置即可. 证明一:有一个坐标未移动,见例题3(UVA11300) 证明二:没有点移动到相同位置. 假设x,y移动到相同位置,那么他们的pos四舍五入相同,最多差0.9999,小于1.但是根据我们的做法,移动前坐标相差大于一,故不可能. #include<cstdio> #include<cmath> us…
题目大意 在一个圆周长为10000的圆上等距离分布n个雕塑,现在有m个新加入的雕塑(还是要求等距离摆放),问n个雕塑移动的总距离的最小值. Solution 显然必然会有一个雕塑不移动,所以可以直接不管他(这个证明的话可以通过代数+中位数证明). 设每一个雕塑移动的距离为\(x_i\),那么显然就是最小化\(\sum_{i=1}^nx_i\) 然后就是直接考虑定一个位置然后把两种情况的都算出来就可以了. //|--------------------------------|\\ //|auth…
一开始不知道在想啥,竟然写了个双重for循环的.T T一直WA,又没效率. T T然后在纸上模拟演算,改了,就AC了 以后做题果断要先模拟一下例子...能加深对题目的理解. 当教训吧..太懒导致写了好久.. #include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { int n,m; while(cin>>n>>m) { double…
Graveyard Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 1654   Accepted: 840   Special Judge Description Programming contests became so popular in the year 2397 that the governor of New Earck — the largest human-inhabited planet of the…
1255. Graveyard of the Cosa Nostra Time limit: 1.0 secondMemory limit: 64 MB There is a custom among the Ural Mafiosi — a big Mafioso’s coffin is to be carried by all his subordinates. The length of the coffin (in meters) equals to the number of the…
Description   Programming contests became so popular in the year 2397 that the governor of New Earck -- the largest human-inhabited planet of the galaxy -- opened a special Alley of Contestant Memories (ACM) at the local graveyard. The ACM encircles…
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000即为距离: 详细解释:http://www.cnblogs.com/zywscq/p/4268556.html */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath&…
Graveyard Programming contests became so popular in the year 2397 that the governor of New Earck -- the largest human-inhabited planet of the galaxy -- opened a special Alley of Contestant Memories (ACM) at the local graveyard. The ACM encircles a gr…
题目链接:1388 - Graveyard 题目大意:在一个周长为10000的圆形水池旁有n个等距离的雕塑,现在要再添加m个雕塑,为了使得n + m个雕塑等距离,需要移动一些雕塑,问如何使得移动的总位移最小,输出最小值. 解题思路:可以将周长展成坐标来看,原来的n个雕塑在x[i] = i / n,而移动过后的位置应该在y[i] = i / (n + m),根据贪心的思想,x[i]肯定要移动到最近的y[j]上,问题就解决了,然后就讨论说会不会有两个雕像移动到同一个位置,大白书里给出了很好的反证法,…
POJ2100 Graveyard Design 题目大意:给定一个数n,求出一段连续的正整数的平方和等于n的方案数,并输出这些方案,注意输出格式: 循环判断条件可以适当剪支,提高效率,(1^2+2^2+..n^2)=n*(n+1)*(2n+1)/6; 尺取时一定要注意循环终止条件的判断. #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <…