80求助!

P1150 Peter 的烟

lijunxian_0818_2 @ 2024-11-09 19:42:47

#include<bits/stdc++.h>
using namespace std;
int n,k;
int main() {
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n>>k;
    int o=n/k;
    cout<<o+n;
    return 0;
}

by xywuyu @ 2024-11-09 19:45:47

@lijunxian_0818_2 o可能大于3,还能再换烟


by xywuyu @ 2024-11-09 19:46:01

#include<iostream>
using namespace std;
int main()
{
    int a,b,c,n,k;
    cin>>n>>k;
    a+=n;
    while (n>=k)
    {
    b=n/k;a+=b;
    n=(b+n%k);}
cout<<a;

    return 0;
 } 

by lijunxian_0818_2 @ 2024-11-09 19:46:45

@xywuyu

谢谢大佬!已私聊!


|