第三个测试点超时,求助大佬

P1150 Peter 的烟

usingns卍 @ 2023-08-29 11:12:23

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n=0,k=0;
    scanf("%d%d",&n,&k);
    int sum=n;
    int jishu,ss,jishu1=n/k;
    sum=sum+jishu1;
    ss=n%k;
    jishu=jishu1+ss;
    while(jishu>=k)
    {
        jishu=jishu/k;
        sum=sum+jishu;
        jishu=jishu+(jishu%k);

    }
    printf("%d",sum);
    return 0;
}

by 2024yejinghong @ 2023-08-31 12:55:19

求关


by 2024yejinghong @ 2023-08-31 12:56:25

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

by 2024yejinghong @ 2023-08-31 12:57:13

最短程序


|