女人被狂躁到高潮视频免费无遮挡,内射人妻骚骚骚,免费人成小说在线观看网站,九九影院午夜理论片少妇,免费av永久免费网址

當前位置:首頁 > > 充電吧
[導(dǎo)讀]題目鏈接:HDU 4355 題面: Party All the Time Time Limit: 6000/2000 MS (Java/Others)????Memory Limit: 65536

題目鏈接:HDU 4355


題面:

Party All the Time Time Limit: 6000/2000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5266????Accepted Submission(s): 1625


Problem Description In the Dark forest, there is a Fairy kingdom where all the spirits will go together and Celebrate the harvest every year. But there is one thing you may not know that they hate walking so much that they would prefer to stay at home if they need to walk a long way.According to our observation,a spirit weighing W will increase its unhappyness for S3*W units if it walks a distance of S kilometers.
Now give you every spirit's weight and location,find the best place to celebrate the harvest which make the sum of unhappyness of every spirit the least. ?
Input The first line of the input is the number T(T<=20), which is the number of cases followed. The first line of each case consists of one integer N(1<=N<=50000), indicating the number of spirits. Then comes N lines in the order that x[i]<=x[i+1] for all i(1<=ii,Wi, representing the location and the weight of the i-th spirit. ( |xi|<=106, 0i<15 ) ?
Output For each test case, please output a line which is "Case #X: Y", X means the number of the test case and Y means the minimum sum of unhappyness which is rounded to the nearest integer. ?
Sample Input
1
4
0.6 5
3.9 10
5.1 7
8.4 10

?

Sample Output
Case #1: 832

?

Author Enterpaise@UESTC_Goldfinger ?
Source 2012 Multi-University Training Contest 6


題意:

??? 給定一維上若干點xi,每個點有對應(yīng)的權(quán)值wi,求一個點的位置p,使得sigma? fabs(p-xi)^3*wi最小。


解題:

? 看了網(wǎng)上現(xiàn)有的所有博客,都是直接說是個凸函數(shù),三分一下就好。求導(dǎo)好像也不直觀,也不知道具體是怎么證明的,姑且認為是個開口向上的二次函數(shù)(因為求的是最小值,且直觀上,p的位置肯定是在中間好),那么三分就可以求解了,需要注意的是,這題C++應(yīng)該是會T的,交G++才能過,然后向最近位取舍,應(yīng)該用%.0lf輸出。

?? 【三分性質(zhì)】

??????? 將區(qū)間三等分,取左等分點為lmid,右等分點為rmid,比如此題,二次函數(shù)開口向上,那么就算lmid的函數(shù)值為lv,rmid的函數(shù)值為rmid,比較lv和rv的值,假設(shè)最小值不在lmid和rmid之間,在兩側(cè),那么lv,rv哪個更小,其對應(yīng)的等分點就更接近最值,故而舍棄大的那邊。倘若,最小值在lmid和rmid之間,那么無論舍棄哪一邊,都不會丟棄最值,同時達到逼近最值的效果,因為最值在何處,我們是不知道的,故而和第一種情況相統(tǒng)一,舍棄較大的一邊。


代碼:

#include 
#include 
#include 
#include 
#include 
#include 
#define LL long long
#define eps 1e-8
using namespace std;
double x[50010],w[50010];
int n;
double cal(double y)
{
	double tmp,res=0.0;
	for(int i=0;ieps)
		{
			double lmid,rmid,lv,rv;
			lmid=(ri-le)/3+le;
			rmid=ri-(ri-le)/3;
            lv=cal(lmid);
			rv=cal(rmid);
			if(lv>rv)
				le=lmid;
			else
				ri=rmid;
		}
		printf("Case #%d: %.0lfn",i,cal(le));
	}
	return 0;
}


本站聲明: 本文章由作者或相關(guān)機構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉(zhuǎn)載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請及時聯(lián)系本站刪除。
換一批
延伸閱讀

晶體管開關(guān)電路的設(shè)計以及如何提高其開關(guān)速度

關(guān)鍵字: 體管 開關(guān) 技巧

你知道電子元器件應(yīng)該如何檢測嗎?小小的電子元器件看似微小,實則是很重要的組成部分之一。因為電子設(shè)備出現(xiàn)故障現(xiàn)象,很大一部分情況是由于電子元器件失效或損壞所導(dǎo)致。如此一來,檢測電子元器件成為很重要的事,那么對于電子元器件檢...

關(guān)鍵字: 技巧 檢測經(jīng)驗 電子元器件

你知道怎么學習單片機嗎?有很多剛?cè)胄械某鯇W者工程師在單片機這個領(lǐng)域經(jīng)常是蒙圈的狀態(tài),完全不知道該從何下手,在開發(fā)過程中:代碼的使用效率問題、單片機抗干擾性、可靠性等問題經(jīng)常困擾著他們。為此,小編歸納總結(jié)出單片機開發(fā)中應(yīng)該...

關(guān)鍵字: 單片機 技巧 電路

現(xiàn)在的電路越來越多,但是有一個關(guān)鍵問題很重要,那就是散熱,對于電子設(shè)備來說,工作時都會產(chǎn)生一定的熱量,從而使設(shè)備內(nèi)部溫度迅速上升,如果不及時將該熱量散發(fā)出去,設(shè)備就會持續(xù)的升溫,器件就會因過熱而失效,電子設(shè)備的可靠性能就...

關(guān)鍵字: PCB 技巧 散熱

題目鏈接:hdu 3062 題面: Party Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 32768/32768 K (Jav

關(guān)鍵字: hdu 入門

題目鏈接:HDU 4544 題面: 湫湫系列故事——消滅兔子 Time Limit: 3000/1000 MS (Java/Others)????Memory Limit: 65535/32768

關(guān)鍵字: hdu 貪心

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=3911 題面: Black And White Time Limit: 9000/3000 MS (

關(guān)鍵字: hdu 線段樹

題目鏈接:HDU 5754 題面: Life Winner Bo Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 131072/13

關(guān)鍵字: hdu 博弈

題目鏈接:HDU 2045 題面: 不容易系列之(3)—— LELE的RPG難題 Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 6

關(guān)鍵字: hdu 入門

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=5071 題面: Chat Time Limit: 2000/1000 MS (Java/Others

關(guān)鍵字: hdu 區(qū)域賽
關(guān)閉