AC 链接


The aspiring Roy the Robber has seen a lot of American movies, and knows that the bad guys usually gets caught in the end, often because they become too greedy. He has decided to work in the lucrative business of bank robbery only for a short while, before retiring to a comfortable job at a university.For a few months now, Roy has been assessing the security of various banks and the amount of cash they hold. He wants to make a calculated risk, and grab as much money as possible.His mother, Ola, has decided upon a tolerable probability of getting caught. She feels that he is safe enough if the banks he robs together give a probability less than this.


给你 n 个银行,银行的钱数和被抓的概率,要求被抓概率小于 k 且拿到更多的钱




using namespace std;
double f[12000];
int wei[1200];
double c[1200];

int main(){
    int t; cin >> t;
    double db; int n;
    cin >> db >> n;
    db = 1-db;
    int tot = 0;
    for(int i=1;i<=n;i++){
        cin >> wei[i] >> c[i];
        tot += wei[i];
        c[i] = 1.0-c[i];
    f[0] = 1;
    for(int i=1;i<=n;i++){
        for(int j=tot;j>=wei[i];j--){
        f[j] = max(f[j],f[j-wei[i]]*c[i]);
    for(int i=tot;i>=0;i--){
    return 0;

分类: 文章

0 条评论


Avatar placeholder

您的电子邮箱地址不会被公开。 必填项已用 * 标注