Hangzhou Electric HDU ACM 1555 How is many days?

Source: Internet
Author: User

How many days? Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 6194 Accepted Submission (s): 3624


Problem Description8600 's mobile phone consumption of 1 yuan per day, each consumption of K yuan can be donated 1 yuan, a start 8600 has m yuan, how many days can I ask?

Input inputs include multiple test instances. Each test instance consists of 2 integers M, K, (2 <= k <= M <= 1000). M = 0, k = 0 indicates the end of the input.
Output outputs an integer for each test instance that represents the number of days that the M-element can be used.

Sample Input
2 24 30 0

Sample Output
35

Author8600
Sourcehdu 2006-12 Programming Contes bored, study day by day until the money is 0.
#include <iostream>using namespace Std;int main () {int M,k;while (cin>>m>>k,m+k) {int day=0,count=0; while (m) {day++;count++;m--;if (count==k) {m++;count=0;}} Cout<<day<<endl;} return 0;}

Hangzhou Electric HDU ACM 1555 How is many days?

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.