# The story of Little P--The magic DotA backpack __sdut

Source: Internet
Author: User
Tags dota

The story of Little P--The magic DotA

topic Description Small p very like to play DotA, no matter day and night play, the result he even dream is inside the picture, one night little p just lie down to do a magical dream ... The undead Lich King pays his wages, the death knight gets an n dollar bill (remember, only one note), in order to prevent his frequent death in the fight, he decided to buy some props for himself, so he came to the Goblin shop before. Death Knight: "I want to buy props!" Goblin businessman: "We have three props here, blood bottles 150 pieces of one, magic medicine 200 pieces of one, invincible Potion 350 one." Death Knight: "OK, give me a blood bottle." He said he pulled out the N-dollar bill and handed it to the Goblin merchant. Goblin businessman: "I forgot to remind you that we do not find customers here the habit of money, much of the money we all when the tip of the pack, hey." Death Knight: "..." Death Knight thought, instead of the money as a tip to send him a little more than his own props, anyway, after all to buy, early bought to put at home or not, but to make it as little as possible to earn him tips. Now the Death Knight feels his IQ is not enough, so I hope little P help him calculate, at least he will give the Goblin merchants how much tips. But the IQ of small p is a famous "can't bear to look straight" Ah, smart extraordinary you so you can help him. The first line of input data is an integer T (1<=t<=100) that represents the number of test data. Then the T-row test data, each test data contains only a positive integer N (1<=n<=10000),   n represents the face value of the money in the Death Knight's hand. Note: The Goblin store has only three props described in the question.   output for each set of test data, please output the Death Knight at least how much money to waste to the goblin businessman as a tip. Sample Input

2
380
200
Sample Output

0
#include <algorithm>
#include <stdio.h>
#include <string.h>
#define INF 10001
using namespace std;
int Dp[inf];
int main () {
int i, J, T, N, a[3]={150, MB};
scanf ("%d", &t);
while (t--) {
scanf ("%d", &n);
memset (DP, 0, sizeof (DP));
For (i=0 i<3; i++)
for (j=a[i) j<=n; J + +)
dp[j] = max (Dp[j, Dp[j-a[i]] + a[i]);
printf ("%d\n", N-dp[n]);
return 0;
}

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.