HDU 1864 最大報銷額 DP

2021-09-08 03:15:19 字數 853 閱讀 5834

這一題的題義真的讓人很傷神啊。其中不超過600元,是指某一類物品的總和不超過600元,1000元是指整張發票的錢不超過1000元,對於浮點數,我們將其統一乘以100。

該題揹包的體積就是發票數,對於第 i 張發票,其最大報銷額就是 dp[i] = max[ ( dp[j]+fee[i] )  <= limit], 其中dp[j]可達(滿足在1~i-1張發票之前能夠報銷j張發票,其總和為不超過額定最大報銷額的最大值)。

**如下:

#include #include 

#include

using

namespace

std;

int m, n, fee[35], cnt, dp[35], fe2[5

];const

int smax = 60000, tmax = 100000

;inline

int max(int x, int

y)int getdata(int &fee)

if (ss-'

a'>=0 && ss-'a'

<=2

) }

else

}return flag ? 0 : 1;}

void zero_one(int

x) }

}void

dp()

}int

main()

}dp();

for (int i = cnt; i >= 0; --i)

}printf(

"%.2lf\n

", max * 0.01

); }

return0;

}

HDU 1864 最大報銷額

這個題是乙個揹包題,要求求出能夠報賬的最大金額 思路 把每張發票的報賬總額算出來,然後跑一次01揹包即可 注意 1 如果發票中含有a b c以外的專案,則不可以報賬 2 發票中可能含有多個a專案,判斷超總額的時候需先累加 3 對小數的處理可以先乘以100 include include includ...

HDU 1864 最大報銷額

最大報銷額 time limit 1000ms memory limit 32768kb 64bit io format i64d i64u submit status description 現有一筆經費可以報銷一定額度的發票。允許報銷的發票型別包括買圖書 a類 文具 b類 差旅 c類 要求每張發...

hdu 1864 最大報銷額

problem description 現有一筆經費可以報銷一定額度的發票。允許報銷的發票型別包括買圖書 a類 文具 b類 差旅 c類 要求每張發票的總額不得超過1000元,每張發票上,單項物品的價值不得超過600元。現請你編寫程式,在給出的一堆發票中找出可以報銷的 不超過給定額度的最大報銷額。in...