"TK" 1024: Mobile phone charges

Source: Internet
Author: User
Tags ming

1024: Mobile phone time limit: 1 Sec memory limit: MB
Submitted by: 2500 Resolution: 1250
Submitted State [Download (1 RMB)] The topic describes Xiao Ming's mobile phone daily consumption of 1 yuan, each consumption of K yuan can be donated 1 yuan, at the beginning, Xiao Ming has m yuan, how many days can I ask? The input input includes multiple test instances. Each test instance consists of 2 integer m,k (2<=k<=m<=1000). M=0,k=0 represents the end of the input. The 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


1#include <stdio.h>2 intMain ()3 {4      intm,k,d;5       while(SCANF ("%d%d", &m,&k) &&m| |k)6      {7D=0;//Be aware of the initialization location! If you put it in a different global result! 8           while(m--//Money is always reduced before welfare, minus 0 to exit9          {Tend++and//The days passed d+1 One              if(d%k==0) Am++and//When it comes time to spend k dollars, that's when you return to m+1. -          } -printf"%d\n", d); the      } -      return 0; -}

"TK" 1024: Mobile phone charges

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.