# Fzu 1150 farmer Bill's Problem

Source: Internet
Author: User
Tags integer numbers
Accept: 525 submit: 1137
Time Limit: 1000 msec memory limit: 32768 kb Problem Description

Peter hasNCigarettes. He smokes them one by one keeping all the butts. OutK> 1 butts he can roll a new cigarette.

How many cigarettes can Peter have?

Input

Input is a sequence of lines. Each line contains two integer numbers giving the valuesNAndK.

Output

For each line of input, output one integer number on a separate line giving the maximum number of cigarettes that Peter can have.

Sample input4 3 10 3 100 5 sample output5 14 124 // The logic is simple, but let me TLE # Include <iostream> <br/> using namespace STD; <br/> int main () <br/> {<br/> int N, K, T; <br/> unsigned _ int64 re; <br/> while (scanf ("% d", & N, & K )! = EOF) <br/>{< br/> Re = 0; <br/> while (n> = K) <br/> {<br/> T = N/K; <br/> re + = T * k; <br/> N = T + N % K; <br/>}< br/> printf ("% i64u/N", RE + n); <br/>}< br/> return 0; <br/>}Times ....
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.