哥哥们,为什么只得了90分

P1150 Peter 的烟

zhangshudong @ 2023-01-11 19:48:15

#include<iostream>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int sum = n, sump = 0, m;
    while (n >= k)
    {
        n = n / k;
        sump = sum - (n * k);
        m = n + sump;
        sum = sum + n;
    }
    cout << sum;
    return 0;
}

by sandwich03 @ 2023-01-11 20:09:21

@zhangshudong 这位大哥,请问你m是干啥的?


by zhangshudong @ 2023-01-12 18:56:40

@linzhi123 第一次换完,然后等第二次换的时候剩余的烟蒂


by zhangshudong @ 2023-01-12 19:01:43

#include<iostream>
using namespace std;
int main()
{
    int n, k;
    cin >> n >> k;
    int sum = n, sump = 0, m;
    while (n >= k)
    {
        n = n / k;
        sump = sum - (n * k);
        m = n + sump;
        sum = sum + n;
        n = m;
    }
    cout << sum;
    return 0;
}

@linzhi123


by zhangshudong @ 2023-01-12 19:02:22

@linzhi123 哥,这样子哪错了


by sandwich03 @ 2023-01-12 19:23:36

挂个代码吧

#include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int sum=n,m;
    while(n>=k)
    {
        m=n/k;//第x次用烟蒂换的烟
        n=n-(m*k);//扣掉用掉的烟蒂
        sum=sum+m;//计数
        n+=m;//这次抽完后剩下的
    }
    cout<<sum;
    return 0;
}

看我打的这么辛苦,给个关注呗 @zhangshudong


by zhangshudong @ 2023-01-12 19:48:39

@linzhi123 好的,小问题


|