The question : Yes n Kind of food , Every kind of food can bring Qiuqiu a sense of happiness a, And it will bring her b A lot of calories , And then make sure she doesn't eat more calories a day than m, Altogether n Kind of food , Ask what you can get

What is the greatest happiness ?

Problem solving report : At first I thought it was 01 knapsack , I didn't look at the question , Then I found that the title didn't say that every kind of food can only be eaten once , It's a complete backpack , At first I thought the second set of test data was wrong , speechless ...

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std; int a[],b[],ans[]; int main()
{
int n,m;
while(scanf("%d",&n)!=EOF)
{
for(int i = ;i < n;++i)
scanf("%d%d",&a[i],&b[i]);
scanf("%d",&m);
memset(ans,,sizeof(ans));
for(int i = ;i < n;++i)
for(int k = ;k <= m / b[i];++k)
for(int j = m;j >= k * b[i];--j)
ans[j] = max(ans[j],ans[j-k * b[i]] + k * a[i]);
int Mtot = ans[];
for(int i = ;i <= m;++i)
Mtot = max(ans[i],Mtot);
printf("%d\n",Mtot);
}
return ;
}

HDU 4508 Qiuqiu series stories —— Lose weight I ( Completely backpack ) More articles about

  1. HDU 4508 Qiuqiu series stories —— Lose weight I( It's all backpacks )

    HDU 4508 Qiuqiu series stories -- Lose weight I( It's all backpacks ) http://acm.hdu.edu.cn/showproblem.php?pid=4508 The question : Yes n Kind of food , Every kind of food can get val[i ...

  2. Complete knapsack problem : Qiuqiu series stories ―― Lose weight I(HDU 4508)

    Qiuqiu series stories ―― Lose weight I  HDU 4508 A naked full backpack #include<iostream> #include<algorithm> #include<stdio ...

  3. HDOJ(HDU).4508 Qiuqiu series stories ―― Lose weight I (DP Completely backpack )

    HDOJ(HDU).4508 Qiuqiu series stories ―― Lose weight I (DP Completely backpack ) Problem analysis Naked backpack Code Overview #include <iostream> #include <cstdio& ...

  4. HDUOJ---- Qiuqiu series stories —— Lose weight I

    Qiuqiu series stories —— Lose weight I Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tota ...

  5. hdu4508 Completely backpack , Qiuqiu series stories —— Lose weight I

    Qiuqiu series stories —— Lose weight I about 01 Backpacks and full backpacks , When I was about to fall asleep last night , All of a sudden, inspiration difference :dp[i][v] Before presentation i Items are just put into a capacity of v The maximum value that you can get from your backpack In the second cycle ,01 It's a reverse cycle , because ...

  6. HDUOJ----4509 Qiuqiu series stories —— Lose weight II

    Qiuqiu series stories —— Lose weight II Time Limit: 5000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Tot ...

  7. G - Qiuqiu series stories —— Lose weight I

    G -  Qiuqiu series stories —— Lose weight I Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u De ...

  8. M - Qiuqiu series stories —— Lose weight I

    M - Qiuqiu series stories -- Lose weight I For food , The happiest thing for Chinese New Year is to eat , Not one of them. ! But for girls , calories ( Quantity of heat ) It's a natural enemy ! Senior beauty Qiu Qiu knows " Fat as a mountain , Fat as silk " The truth , the ...

  9. HDU 4508 Qiuqiu series stories —— Lose weight I (2013 The first race of Tencent programming Marathon )

    http://acm.hdu.edu.cn/showproblem.php?pid=4508 The main idea of the topic : Given some data . Each group of data is represented by an integer n Start , The daily food list is n Kind of food .  Next n That's ok , Two per line ...

  10. 【 Completely backpack 】HDU 4508 Qiuqiu series stories —— Lose weight I

    Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other) Total Submission(s) ...

Random recommendation

  1. Android ExpandableListView Pull down refresh implementation of

    The control is modified according to PullToRefreshList We need to change our mechanism The following is true. ExpandableListView An extension of package com.up91.gwy.view.componet; import ...

  2. git push --no-thin

    Sometimes we do git push Will a new branch Push to the remote warehouse , Will be blocked by the remote repository . Maybe we don't have the corresponding authority . However , I am here git push When it's time to add --no-thin Parameters ...

  3. Controller It should only store the code that can't be reused ( turn )

    MVC The history of MVC, The full name is Model View Controller, It's a model (model)- View (view)- controller (controller) Abbreviation . It represents a common client software development framework ...

  4. One line of code ThoughtWorks Interview questions

    I saw an interesting topic on Weibo today . As python My brain powder , Natural itching . Here's the title . FizzBuzzWhizz You are a PE teacher . When a class is five minutes away from class , You decided to play a game . At this time there is 100 Five students are in class ...

  5. [GitHub] Lesson four : Merging branches

    The two local branches merge Start with the simplest case . Now there's only one project master Branch , I'll build a new one idea Branch , Realize your ideas ,commit once . That's the situation in the warehouse now This is the love I have seen before ...

  6. mssql sqlserver text Data type topic description

    Abstract : Share below text Data type introduction and processing text Functions involved in data types , As shown below : text Introduction to data types : mssql sqlserver Introduction to common data types mssql sqlserver tex ...

  7. 【 original 】 Big data foundation Quartz(1) brief introduction 、 Source code parsing

    A brief introduction Official website http://www.quartz-scheduler.org/ What is the Quartz Job Scheduling Library? Quartz is a richl ...

  8. linux ubuntu lnmp Environment building

    1.# install Apache2, at present 163 The source of this is 2.2.22 edition 02.sudo apt-get install apache203. 04.# install MySQL, at present 163 The source of this is 5.5.24 edition 05.apt-g ...

  9. Oracle High water level indicates and releases table space , Speed up table queries

    Introduction of high water level The database has been running for a while , After some column deletions . Insert . Changing the high water mark of some tables may be very different from the actual data stored in the tables , In order to improve the efficiency of searching the table , It is recommended to shrink these tables : Look up the high water mark table Lookup table ...

  10. SSH Secure Shell Client The solution to Chinese disorder

    http://www.cnblogs.com/52linux/archive/2012/03/24/2415082.html Scheme 1 : modify linux Environment variables for the server Use linux, There is a ...