这种情况下,用DP解的时间复杂度也是O(nk), 算法如下,方便起见,把其它2个种情况
也一起说了。
Input:
1.n种不同的面值,数组a[1,2...n], 每个a[i]是第i个面值的value
2.每种面值限定的个数,数组b[1,2,...n],每个b[i]是第i个面值限定的个数
3.需要组成的目标值,k
要求以上所有的数都是正整数
Output:
最小数目的硬币,使得他们的面值和是K, 要求第i个面值的硬币不能超过b[i]
1.先定义DP的sub problem
sub(t,m): 表示用前m种面值的所有硬币(即a[1,2...m])来组成面值和为t所需要的最
小数目的硬币的个数,要求第i个面值的硬币不能超过b[i]
所以我们的最终目标是求sub(k,n)
2.定义DP的dependency relation
Version (1): 要求每种面值只用一次,即b[i]=1, for each i, then
sub(t,m) = min{sub(t-a[m],m-1)+1, sub(t,m-1)}
即:为了求sub(t,m),我们有2种选择:或者用面值m的硬币,或者不用
Ve
这里是我以前一个project的部分code,
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If Not Cancel Then
RemoveMenu
End If
End Sub
Private Sub Workbook_Open()
CreateMenu
End Sub
Sub CreateMenu()
Dim CBPop As CommandBarControl
Dim i As Integer
'Add "Simulate" menu to main menu bar and chart menu bar
AddSimulateMenu "Worksheet Menu Bar"
AddSimulateMenu "Chart Menu Bar"
End Sub
Sub AddSimulateMenu(MenuBarName As String)
Dim CBPop As CommandBarControl
Dim CBCtl
两块儿地:sub1 & sub2.
在上面做实验,每年的1月1日做,从91年做到00年,一共10年(year1-year10).
在每块儿地上做test vs control,得出trt1 @ trt2.
91年做10次相同试验,n1-n10
92年做20次相同试验,n1-n20,
.....
00年做100次,n1-n100.
需要我写一个3-way mixed model的code
我的code是:
proc mixed;
class trt sub year;
model y=sub year sub*year;
random trt trt*sub trt*year trt*sub*year;
repeated ?????/ sub=sub type=cs r un;
这里的?????应该写什么啊?
在每个最小的cell里面observation是repeated.好像我以前从来没有遇到过这种问题啊.
另外,我这个的code没有错吧,人家好像很满意的样子
http://www.zerohedge.com/article/deer-goes-through-headlights
DEER Goes Through The Headlights
Submitted by Tyler Durden on 03/21/2011 13:54 -0400
After a two weeks ago we presented a report from Alfred Little research
indicating just what a potential scam the latest alledged Chinese fraud DEER
is, the stock manipulation derby that ensued to keep the price above $11
was beyond criminal. That said, we are happy to present the latest piece of
evidence from Alfred Little chipping away at the facade... 阅读全帖
China's pirate patrol submarine is too noisy, say naval experts
PUBLISHED : Sunday, 03 May, 2015, 4:40am
UPDATED : Sunday, 03 May, 2015, 4:40am
COMMENTS: 13
Minnie Chan
Minnie Chan
[email protected]/* */
571SHARE
13
PrintEmail
China's recent deployment of a nuclear submarine for an antipiracy mission
in the Gulf of Aden may have caused unease among its neighbours, but naval
experts say the Type 091 vessel is unlikely to pose any real threat because
of the noise it generates.
The experts sa... 阅读全帖
You are really ignorant on the issue.
The problem with sub-prime mortgage default is because a lot of mortgage
lenders stopped really verifying incomes. The government law only asked the
bank to make sub-prime loans to people who don't have enough down payment
and/or credit history, it never asked the bank to ignore the basic lending
standard.
The higher default risk carried by sub-prime loans was never the issue,
because it's higher interest rate, fees and mortgage insurance requirement
alre... 阅读全帖
For the speakers that I have audited. Maggie 1.7 does sound a lot better
than traditional cone speakers as far as I can tell --- the clarity is
unmatched by the traditional speakers, although I think ML ElectroMotion is
probably even better in clarity. However I think Maggie 1.7 is very
sensitive to the quality of amplifiers. Yesterday I audited Maggie 1.7 first
on a 1600 amplifier and then a 16,000 one, definitely heard the difference.
I am doing my research online and found the following, thin... 阅读全帖
I guess we can pass the definition of in-order and level-order traversal. :-
).
For example:
50
/ \
10 60
/ \ / \
5 20 55 70
/ / \
51 65 80
The in-order and level-order traversal of the above tree are:
5, 10, 20, 50, 51, 55, 60, 65, 70, 80
50, 10, 60, 5, 20, 55, 70, 51, 65, 80
My idea:
(1) traversal the level-order array to find out the first element which
appears in the in-order array. We call this element as current root.
(2) find the in... 阅读全帖
其实就brut force.基本O(n).不符合的很快就return,写起来也简单。
bool BrutForceCheck(char* str, int sub, int n)
{
if (n / sub*sub != n) return false;
int m = n / sub;
if (m < 2) return false;
int k;
for (int i = 1; i < m; i++)
{
k = i*sub;
for (int j = 0; j < sub; j++)
{
if (str[k + j] != str[j]) return false;
}
}
return true;
}
bool CheckIfStrHasInternalRepeat(char* str)
{
bool rtn = false;
int length = strlen(str);
for (int i = ... 阅读全帖
刚学python,菜鸟一个,见笑了。
str="Heeololeo"
sub=["ol","ee"]
for i in range(len(sub)-1):
for j in range(len(str)-1):
if str[j:j+len(sub[i])]==sub[i]:
str=str.replace(sub[i],"")
return str
上面的循环只能去掉ol,无法执行第二次大循环。
而且感觉还应该在最外面加一个循环,break条件是 sub[i]不再是最近一次结果的
substring。
承蒙大家bless,I140顺利通过。分享一点我的个人经验,但愿有用。我claim了老三项
,外加media report.发现想分享的太多,缓慢填坑,一天写不完不要拍我。~~LOL~ 今
天先讲一下背景及整体的布局和装订。
我的background by the time I140 efiled:
十几篇journal publications and conference reports 。all English (我没有分开
journal or conference,因为本身有好几篇conference presentation后来又publish
在journal上,而且采用“reports" rather than "abstracts" so that it may sound
more impressive。没办法,背景太弱,只好玩点文字游戏,在PP的短时间内,IO需要
快速浏览,个人认为可能会有点用).
review ~ 90 journal papers and conference abstracts in <2 years (大家看到了
没有,abstract又... 阅读全帖
承蒙大家bless,I140顺利通过。分享一点我的个人经验,但愿有用。我claim了老三项
,外加media report.发现想分享的太多,缓慢填坑,一天写不完不要拍我。~~LOL~ 今
天先讲一下背景及整体的布局和装订。
我的background by the time I140 efiled:
十几篇journal publications and conference reports 。all English, >85% first
author (我没有分开
journal or conference,因为本身有好几篇conference presentation后来又publish
在journal上,而且采用“reports" rather than "abstracts" so that it may sound
more impressive。没办法,背景太弱,只好玩点文字游戏,在PP的短时间内,IO需要
快速浏览,个人认为可能会有点用).
review ~ 90 journal papers and conference abstracts in <2 years ... 阅读全帖
Basically, the topic for the remaining places go out, and I mention it
(Not for normal indicators of things to say). Article is very long (I also d
eleted some), as much detail as possible, to see you
Understand the Chinese remainder EB quota is the basis for the (for PD).
One. From the spirit of the legislation for the remaining places to see (fir
st program)
Countries to the United States is bound by the number of migrants. Such as t
he FB + EB does not exceed 7%.
Immigration law to prevent in... 阅读全帖
我喜欢9mm,用开花弹力量也够了。
Glock G26 Sub-Compact: Haggle Price $500-$530
Polymer frame. Weight: 19.8 oz., Barrel: 3.50", Magazine: 10 rounds
The Glock 26 was specially developed for concealed carry. The G26 is a good
backup companion pistol for those that carry the full size 9mm Glock. There
are tons of accessories and holster choices for the Glock 26. The most
popular police backup pistol of all time.
Diamondback DB9: Haggle Price $350-$380
Polymer frame. Weight: 11.0 oz., Barrel: 3.00", Magazine: 6 rou... 阅读全帖
http://www.time-to-run.com/training/10k/sub50.htm
这个网站貌似特色的training program 是10K,从sub 50, sub 45, sub 40, sub 35,
sub 33 一直到sub 31。对死磕10K成绩有兴趣的可以试试。
一般是跑个4K time trial作为一个起始标准以确定quality training的速度。
然后进行一到两个周期的build up cycles(和一般base building cycle概念类似),
每个build up周期三周。
然后进入racing cycle,一个cycle是22天,第19天比赛,从5k到15K的比赛都可以。然
后休息三天。这样进行3到4个racing cycles,也就是两三个月,进入休整期(off
training cycle),完了再build up,如此循环。
几点好处:
* 周期短,比赛次数不少,不断提高的话容易保持兴趣。
* 大周期的安排貌似比较合理。
* 训练针对性强,可操作性不错。
* 小周期不是以周为单位,比较独特。
前面贴的都是二年前写的。想想那就简单把它续到现在吧。
2012年
2012年是我跑步以来唯一的体能下降的一年。11月半马1:28。2013年1月休士顿马拉松3
:03。
后面会把休士顿马拉松报告贴上来。
2012年最大的收获是认识了德州一帮也喜欢跑步的中国人。总体来说比踢球的中国人素
质高。
Houston 2013 Race Report
Training:
8 years into running, I had my bad years. Chicago 2007 and 2010, to name my
famous ones, but 2012 was really the worst because it marked the first time
my fitness declined. There were simply too many things going on in my life
aided by my immaturity to handle them right that my training sunk. 1774
miles was actually ... 阅读全帖
Houston 2013 Race Report
Training:
8 years into running, I had my bad years. Chicago 2007 and 2010, to name my
famous ones, but 2012 was really the worst because it marked the first time
my fitness declined. There were simply too many things going on in my life
aided by my immaturity to handle them right that my training sunk. 1774
miles was actually my second highest, but I never consistently trained more
than 2 months with the longest being 14 in January. In September, I thought
since I didn’t... 阅读全帖
http://www.365runners.com/t2713-oops-i-did-it-again
Prologue
Once upon a time, Tim and I were trashing talking. Tim said something like
Jerry got lucky to break 3 hours and that's why Jerry never did it again.
Ever since then, Jerry wanted to title his next sub 3 report as: Oops, I did
it again!
Training
Training has been lame, if you ever read my blog. But I do want to touch
three highlights:
Dallas marathon cancellation: I was able to pick myself up from the
disappointment within an hour of kn... 阅读全帖
footprint & global agreement
(me~) ((me~)@xxxx.uxxxx.edu)
Sent: Tuesday, November 18, 2014 6:42 PM
As I pointed out that it was all your fault which leaded to these whole
confusion, and have stated in the meeting on Saturday that, I was going to
write a email as a footprint to prevent you from future suffering, and help
myself clear my life here in U of xxxx.
Facts:
- On team meeting *10/7/2014, Tuesday*, always being active and fast towards
projects, m suggested us to install Qt Creator, dow... 阅读全帖
有没有人用过GLOBAL.ASA?
怎么用GLOBAL.ASA,比如怎么调用这个文件?能不能给我一个例子?
比如:
<%
Sub Application_OnStart
Application("visitors")=0
End Sub
Sub Session_OnStart
Application.Lock
Application("visitors")=Application("visitors")+1
Application.UnLock
End Sub
Sub Session_OnEnd
Application.Lock
Application("visitors")=Application("visitors")-1
Application.UnLock
End Sub
%>
怎么能够让它工作起来??
谢了!
请教各位高手一个VBA 的问题,
我有一个Table, 想做个Form, 有三个 Dropdown menu, Name, Event, Country
可以filter, 在subform 里面则显示filter的结果。
所以就写了如下code, 希望可以两个或者三个一起来, 可是不知道为什么就是
不work, 希望高手能帮着看看。
Option Compare Database
Private Sub searchname_AfterUpdate()
Call SearchCriteria
End Sub
Private Sub searchevent_AfterUpdate()
Call SearchCriteria
End Sub
Private Sub searchcountry_AfterUpdate()
Call SearchCriteria
End Sub
Function SearchCriteria()
Dim myname, myevent, mycountry As String
Dim task, strCriteria As String
If IsNull... 阅读全帖
在哪里改变了的呢?我怎么也看不出来。。。
这是我的code:
sub = dir('M*')
save sub sub
clear
load sub
for ii= 1:size(sub,1)
cfg = [];
cd(sub(ii).name)
[run data processing here]
cd ..
end
In fact the code in the loop just data processing...
the whole codes is below:
sub = dir('M*')
save sub sub
clear
load sub
for ii= 1:size(sub,1)
cfg = [];
cd(sub(ii).name)
cfg.data = 'data';
cfg.trialdef.triallength = 2;
cfg = ft_definetrial(cfg);
predelta = ft_preprocessing(cfg);
save predelta predelta
cd ..
end