Created
July 8, 2015 14:35
-
-
Save mob5566/b92de51292373110cdd9 to your computer and use it in GitHub Desktop.
10346 - Peter's Smokes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Tittle: 10346 - Peter's Smokes | |
* Author: Cheng-Shih, Wong | |
* Date: 2015/07/08 | |
*/ | |
// include files | |
#include <bits/stdc++.h> | |
using namespace std; | |
// definitions | |
#define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i ) | |
#define clr(x,v) memset( x, v, sizeof(x) ) | |
// declarations | |
int n, k; | |
// functions | |
// main function | |
int main( void ) | |
{ | |
while( cin >> n >> k ) { | |
int ret = 0; | |
int butts = 0; | |
// solve | |
while( n ) { | |
ret += n; | |
butts += n; | |
n = (butts)/k; | |
butts %= k; | |
} | |
// output | |
cout << ret << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment