90分,第三个点WA

P1150 Peter 的烟

winnipeg @ 2017-09-22 13:27:08

#include<iostream>
#include<cmath>
using namespace std;
int a[1000020],n,i,s,s1=-1,k;
int main()
{
    cin>>n>>k;
    s=n;
    while (n>0)
    {
        n=n/k;
        s+=n;
    }
    cout<<s;
}

by xun薰 @ 2017-09-22 16:42:41

最后n小于k,那你n=n/k,n就为0了,应该当n<k时直接加上n的值,break


by return先生 @ 2017-09-24 14:37:27

呵呵,我都会做,我还是个13岁小孩呢...


by damage @ 2017-10-01 14:29:29

#include<iostream>
using namespace std;
int n,k,sum;
int main()
{
    cin>>n>>k;
    sum=n;
    while(n>=k)
    {
        n-=k;
        n++;
        sum++;
    }
    cout<<sum<<endl;
}

by Komorebi_shine @ 2017-10-05 11:25:46

@return先生 +1


by return先生 @ 2017-10-05 13:32:10

@codevs6666666666 呵呵!


|