c++ 90分求助,第三个点WA

P1150 Peter 的烟

Luna16 @ 2022-01-30 01:35:15

代码如下

#include <iostream>
using namespace std;
int main(){
    int n , k;
    cin >> n >> k;
    int flag = n ;
    for (int i = 0; ; ++i)
    {
        flag = flag + n / k;
        if (n / k < k)
        {
            break;
        }
        n = n / k;
    }
    cout << flag << endl;
    return 0;
}

by 达·芬奇 @ 2022-01-30 01:37:28

#include <bits/stdc++.h>
using namespace std;
int main()
{
        int n,k;
        cin>>n>>k;
        cout<<n+(n-1)/(k-1);
        return 0;
}

拿走


by BlueTiger @ 2022-10-11 21:55:47

@Luna16

#include<iostream>
using namespace std;
int main(){
    int a,b,tot=0,l=0;
    cin>>a>>b;
    while(l>=b){
        l-=b;
        a++;
    }
    while(a>0){
        a--;
        tot++;
        l++;
        if(l>=b){
            l-=b;
            a++;
        }
    }
    cout<<tot<<endl;
    return 0;
}

可能有点麻烦哈


|