nyoj-54-Xiao Ming's savings plan

Source: Internet
Author: User

Xiao Ming's Saving plan time limit: theMs | Memory Limit:65535KB Difficulty:2
Describe

Xiao Ming's pocket money has always been his own management. At the beginning of each month, the mother to Xiao Ming 300 yuan, Xiao Ming will budget this month's expenses, and always do the actual cost and the same budget.
In order to let Xiao Ming learn how to save, mother proposed, Xiaoming can at any time to the whole hundred of money there, to the end of the year she will add 20% back to Xiaoming. So Xiaoming developed a savings plan: the beginning of each month, after getting his mother's allowance, if he expects to have more than 100 yuan or just 100 yuan at the end of this month, he will put the whole hundred of money in the mother there, the rest of the money left in their hands.
For example, in early November Xiao Ming hands still 83 yuan, mother gave Xiaoming 300 yuan. Xiao Ming is expected to spend 180 yuan in November, then he will save 200 yuan in his mother, he left 183 yuan. By the end of November, Xiao Ming will have 3 yuan left in his hand.
Xiaoming found that the main risk of the savings plan was that there was no money to be taken out until the end of the year. It is possible at the beginning of a month, Xiao Ming's money plus this month's mother's money, not enough for this month's original budget. If this happens, xiaoming will have to pinch and compress the budget this month.
Now, according to the month of January 2010 to December, Xiao Ming's budget, judge whether this situation will occur. If not, calculate to the end of 2010, mother will Liangmingping the amount of money plus 20% back to Xiaoming, Xiao Ming's hands will have how much money.

Input
The
first line enters an integer N, which represents the number of groups of test data (n<=10)
Each set of test data entered 12 rows of data, each containing a non-negative integer less than 350, respectively, from January to December Xiao Ming's budget.

Output
Each set of outputs includes one row, which contains only an integer. If a liken is not sufficient in the implementation of the savings plan, the output-x,x represents the first month of this situation, otherwise the output to the end of 2010 Xiao Ming hands will have how much money (if it is a decimal, round to the whole number of digits).

Sample input
129023028020030017034050 90 80 20060
Sample output
-7
Source

Internet


Code:

#include <stdio.h> int Money[13];int main () {int n,i;scanf ("%d", &n), while (n--) {for (i=1;i<=12;++i) {scanf ("%d", &money[i]);} int Save=0,sy=300;for (i=1;i<=12;++i) {if (Sy<money[i]) {printf ("-%d\n", I); break;} Sy-=money[i];if (sy/100) {save+=100* (sy/100); sy%=100;} if (i!=12) sy+=300;} if (i>12)  printf ("%.lf\n", sy+save*1.2);} return 0;}


nyoj-54-Xiao Ming's savings plan

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.