10346 - Peter's Smokes

Problem Link

import java.util.*;
public class uva10346 {
public static void main(String [] args) {
Scanner scn = new Scanner(System.in);
while(scn.hasNextInt()) {
int n = scn.nextInt();
int k = scn.nextInt();
int t = n;
while(n >= k) {
int c = n%k;
if((n%k)!=0) {
int b = n - c;
n = b/k;
t = t+n;
n = n+c;
}
else {
n = n/k;
t = t+n;
n = n+c;
}
}
System.out.println(t);
}
}
}

Share this

Related Posts

:)
:(
hihi
:-)
:D
=D
:-d
;(
;-(
@-)
:P
:o
:>)
(o)
:p
:-?
(p)
:-s
(m)
8-)
:-t
:-b
b-(
:-#
=p~
$-)
(y)
(f)
x-)
(k)
(h)
cheer