题目大意是求出用1、2、3、5、7这5个数字配合+、*、^、!这四种运算符得出表示n(n<=20000)的最简表达式(即所用数字最少)。
显然+和*两种情况的处理都比较简单,比较麻烦的是^和!的运算。不过20000内的!运算情况只有7种,因此可以对!运算进行特别处理。而对于^运算,若x^i=n,则可以用g[n,i]来记录x,通过预处理即可得到20000内所有^运算的方案。同时为了方便起见,最好将4和6的情况也预处理一下。完成了以上预处理后即可,用f[i]表示组成i所需的最少数字,则有几种情况需要处理:
- f[i]=min(f[j]+f[i-j]);
- f[i]=min(f[j]+f[i div j])(i mod j=0);
- f[i]=min(f[g[i,j]]+f[j])(g[i,j]>0);
同时在DP过程中记录下转移到当前状态的前一个状态,这样即可利用递归输出所求表达式。
1651204 2008-09-28 23:42:58 Accepted 1446 FPC 280 444 IwfWcf
太牛了,能不能把代码放上去啊,谢了。。。。。
回复删除要代码请留下邮箱
回复删除qihang0922,instyler max
回复删除tory burch outlet
ralph lauren outlet
gucci borse
jordan pas cher
ugg boots
longchamp handbags
air max
mulberry handbags
timberland boots
uggs on sale
mont blanc
fitflops sale clearance
michael kors handbags
air max 90
ugg sale
louis vuitton pas cher
replica watches
burberry outlet
ugg boots clearance
ugg outlet
fake oakleys
nike tn
pandora jewelry
louboutin
christian louboutin uk
hermes uk
cheap uggs
cheap jerseys
toms shoes
kate spade handbags
gucci shoes
michael kors
nike air force 1
nike air huarache
ray ban outlet
adidas superstar
tod's shoes
q
toms outlet, http://www.tomsoutlet-stores.com/
回复删除nike roshe, http://www.nikerosherunshoes.co.uk/
prada handbags, http://www.pradahandbagsoutlet.co.uk/
soccer jerseys, http://www.cheapsoccerjersey.net/
michael kors outlet store, http://www.michaelkorsoutlet-store.us.com/
true religion jeans, http://www.truereligionjeansoutlets.us.com/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
nike free 5, http://www.nikefree5.us/
louis vuitton bags, http://www.louisvuittonbag.us.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
chanel handbags, http://www.chanelhandbags-outlet.us.com/
louis vuitton handbags, http://www.louisvuittonhandbag.us/
louis vuitton outlet, http://www.louisvuittonoutlet.in.net/
ghd hair straighteners, http://www.ghdhairstraightenerssale.co.uk/
nba jerseys, http://www.nbajerseys.us.com/
coach outlet, http://www.coachoutletstores.com.co/
true religion jeans, http://www.truereligionjeanscanada.com/
swarovski crystal, http://www.swarovskicrystals.co.uk/
mbt shoes, http://www.mbtshoesoutlet.us.com/
michael kors handbags, http://www.michaelkorshandbags.in.net/
chanel handbags, http://www.chanelhandbagsoutlet.in.net/
michael kors outlet online, http://www.michaelkorsoutletonline.in.net/
polo ralph lauren, http://www.poloralphlauren.us.org/
the north face clearance, http://www.thenorthfaceclearances.us.com/
jordan shoes, http://www.jordan-shoes.us.com/
beats by dr dre, http://www.beatsbydrdre-headphones.us.com/
the north face uk, http://www.thenorthfaces.org.uk/
1003maoqiuyun
coach factory outlet
回复删除mbt shoes women
moncler outlet uk
michael kors outlet online
gucci outlet
steelers jerseys
cheap ugg boots
coach outlet online
cheap ray bans
true religion jeans
201612.26chenjinyan
miami heat jersey
回复删除fitflops sale
christian louboutin outlet
ralph lauren uk
ralph lauren polo
ferragamo shoes
packers jerseys
mlb jerseys