Gdufe ACM-1039

Source: Internet
Author: User

Title: http://acm.gdufe.edu.cn/Problem/read/id/1039

Ice Throne time limit:2000/1000ms (java/others) problem Description:
             The undead Lich King pulls the wages, the death Knight gets an n-dollar bill (remember, only a note), in order to prevent his frequent death in the battle, he decided to buy himself some props, so he came to the Goblin shop. Death Knight: "I want to buy props!" Goblin businessman: "We have three kinds of props here, 150 pieces of blood bottle, a magic medicine 200 pieces of one, invincible potion 350 pieces of one." Death Knight: "All Right, give me a blood bottle." 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 have the habit of looking for guests money here, more money we all when the tip received, hey." Death Knight: "..." The Death Knight thought, instead of giving money as a tip, he might as well buy a little prop, anyway, buy it later, buy it at home, but try to keep it as small as possible. Now the Death Knight wants you to help him calculate, at least how much he wants to tip the goblin businessman.
Input:
The first line of the input data is an integer T (1<=t<=100), which represents the number of test data. Then the T-line 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 items described in the title.
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:
2900250
Sample Output:
050

Ideas: In the premise of not more than N, try to find a waste of money the least one

Difficulty: Simple

Code:
1#include <stdio.h>2 intMain ()3 {4     intn,m,a,b,c,d,k;5      while(SCANF ("%d", &n)! =EOF)6     {7          while(n--)8         {9scanf"%d",&m);Tenk=m; One              for(a=0; A * Max<m;a++) A             { -                  for(b=0; $*b+a* Max<m;b++) -                 { the                      for(c=0;; C++) -                     { -d=m-a* Max-b* $-c* -; -                         if(d<0) Break; +                         if(k>d) k=D; -                     } +                 } A             } atx1:printf ("%d\n", k); -         } -     } -     return 0; -}

Gdufe ACM-1039

Related Keywords:

Contact Us

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.