| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
不用背包问题AC,附我的解题方法base[10]={1,1,2,6,24,120,720,5040,40320,362880};
注意到:0!<=1!
0!+1!<=2!
0!+1!+2!<=3!
.....
所以此题我的方法是反复从大到小一个个取数,取过的就记下位置.
然后把这些数加起来,如果刚好相等,就表示YES
如果把 能 取的数都取光,并且这个数不等于输入的数,那就表示这个数NO.
耗时:16MS (注意用scanf)
另外注意是输入负数结束
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator