原创 月餅

月餅是中國人在中秋佳節時吃的一種傳統食品,不同地區有許多不同風味的月餅。現給定所有種類月餅的庫存量、總售價、以及市場的最大需求量,請你計算可以獲得的最大收益是多少。 注意:銷售時允許取出一部分庫存。樣例給出的情形是這樣的:假如

原创 擴展歐幾里得算法(POJ 1061)

分析可知,該題只需求解同餘方程(x+am) %L=(y+an) %L 最小的a即可。 對方程變形可得 a∗(m−n)+k∗L=y−x , k爲一整數 令p=m−n,q=y−x ,有:a∗p+k∗L=q

原创 1183 反正切函數的應用

Description 反正切函數可展開成無窮級數,有如下公式 (其中0 <= x <= 1) 公式(1) 使用反正切函數計算PI是一種常用的方法。例如,最簡單的計算PI的方法: PI=4arctan(1)=4(1

原创 2365 Rope

Description Plotters have barberically hammered N nails into an innocent plane shape, so that one can see now only head

原创 ZOJ 1003

judge函數是怎麼執行的?求問 /*函數不是很懂??????*/ #include<iostream> #include<stdio.h> #include<algorithm> using namespace std; bool

原创 2291 Rotten Ropes

Description Suppose we have n ropes of equal length and we want to use them to lift some heavy object. A tear-off weigh

原创 1299 Polar Explorer

Description You are a intrepid 2-dimensional explorer located at the northern polar reaches of a distant 2-dimensional

原创 ZOJ 1078

/*判斷迴文數: 1,進制分解:用模運算和整除運算即可,每一位存在數組c 2,迴文判斷:將c中按長度len對摺,判斷對應的位是否相同,有一個不同,就不是迴文數*/ #include<iostream> #include<stdio.h>

原创 ZOJ 1058

當伊薩克從一個國家c[i-1]去另一個國家c[i]旅行(i=1和i=n+2是美國,則旅行的國家是i=2~n+1),貨幣匯率是a[c[i-1]][c[i]],四捨五入即可。 #include<iostream> #include<ioman

原创 1045. Bode Plot

題目鏈接: http://poj.org/problem?id=1045 思路: v2=iR=CRd(v1−v2)/dt dv1/dt=−wVssin(wt) dv2/dt=−WVRsin(wt+θ) 所以有:v2=CRw(VR

原创 2242 The Circumference of the Circle

Description To calculate the circumference of a circle seems to be an easy task - provided you know its diameter. But w

原创 1003 Hangover

Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum over

原创 1410 Intersection

Description You are to write a program that has to decide whether a given line segment intersects a given rectangle. A

原创 科學計數法

科學計數法是科學家用來表示很大或很小的數字的一種方便的方法,其滿足正則表達式[+-][1-9]”.”[0-9]+E[+-][0-9]+,即數字的整數部分只有1位,小數部分至少有1位,該數字及其指數部分的正負號即使對正數也必定明確給出。

原创 1401 Factorial

Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers fo