rev='made'/> name='keywords'/> name='author'/> ANURANAN: UVa Solution 10346 : Peter’s Smokes

Welcome Note

Hi,
I'm Anisuzzaman Babla . I am a full stack Android Application Developer. I am working with Android for more than two years. I have completed my graduation from IIT, Jahangirnagar University. I have developed a series of commercially successful apps on Android. Moreover, 10+ of my Apps are live at Google play store. .
Thank You

UVa Solution 10346 : Peter’s Smokes

#include<cstdio>
int main()
{
int have,n,k;
while(scanf(“%d %d”,&n,&k)==2 && k>1)
{
have=n;
while(n>=k)
{
have= have+n/k;
n=(n/k)+(n%k);
}
printf(“%d\n”,have);
}
return 0;
}

2 comments:

  1. what is wrong with my code??

    #include

    int main()
    {
    long long int n,k;
    while(scanf("%lld%lld",&n,&k)!=EOF)
    {
    long long int m=n;
    long long int p=0,rm=0,r;
    while(n>0)
    {
    r=n%k;

    n=n/k;
    p=p+n;

    rm=rm+r;
    if(rm>=k)
    {

    p=p+(rm/k);
    rm=rm%k;
    }

    }
    printf("%lld\n",(p+m));
    }
    return 0;
    }

    ReplyDelete
  2. whats wrong on my code???????????




    #include
    #include
    using namespace std;
    int main()
    {
    int n,k,a,c,b=0;
    while((cin>>n>>k)&&(n>=k)){
    if(k>1){
    a=(n/k);
    if(a>=k)
    b=(a/k);
    c=(n+a+b);
    cout<<c<<endl;
    }
    }
    return 0;
    }

    ReplyDelete