20pts,help

P1150 Peter 的烟

jfy2204 @ 2023-05-29 21:45:01

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

?????


by smart_ @ 2023-06-08 22:00:51

程序应为:

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

by smart_ @ 2023-06-08 22:01:15

大佬看看对不对?


by ML_Galaxy_ @ 2023-07-25 10:02:36

@smart_ 和题解上差不多


by ML_Galaxy_ @ 2023-07-25 10:06:28

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

by smart_ @ 2023-07-26 22:34:13

...这是我写的哦


|