结果是对的,可是显示我的wrong answer on line 1

P1150 Peter 的烟

Chenhexian @ 2023-10-19 11:51:01

#include <stdio.h>
int main()
{
    int n,k,m;
    int add=0;
    scanf("%d %d",&n,&k);
    for(int i=1;i<n;i++){
        if(i%k==0){
            add=add+1;
        }
    }
    printf("%d\n",n+add+add/k);
    return 0;
}

by rainbow_cat @ 2023-10-19 11:52:45

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,k;
    cin>>n>>k;
    cout<<n+(n-1)/(k-1);
    return 0;
} 

|