输入样例都对了,不知道为什么全错,求指出

P1150 Peter 的烟

JshGLJ @ 2023-07-31 15:04:51

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

by 2021JPL @ 2023-07-31 15:38:28

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

by SealMoBurp @ 2023-07-31 15:40:54

@LIUSASA 好像这样就能过了

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

by JshGLJ @ 2023-07-31 19:04:57

@2021JPL 谢谢


|