同90求助

P1150 Peter 的烟

天下第一 @ 2019-07-24 14:12:58

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

by 学而思李老师 @ 2019-07-24 14:36:46

直接用数学做:

#include <cstdio>
using namespace std;
int main(){
    int n, k;
    scanf("%d %d", &n, &k);
    printf("%d", n + (n - 1) / (k - 1));
    return 0;
}

by wypdyxfor163 @ 2019-07-24 15:30:50

@社会我猪酐 在吗


|