2021xiaohu @ 2022-01-13 12:28:17
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,sum,s;
cin>>n>>k;
s=n/k;
sum=n+s+s/k;
cout<<sum<<endl;
return 0;
}
by 编码落寞 @ 2022-01-13 12:48:52
@2021xiaohu
你用数据7 2测试下,少考虑了情况
by 2021xiaohu @ 2022-01-13 12:53:41
@编码落寞 7跟2输出的是12
by 2021xiaohu @ 2022-01-13 12:58:29
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,sum,s;
cin>>n>>k;
s=n/k;
sum=n+s+(s+n%k)/k;
cout<<sum<<endl;
return 0;
}
by 2021xiaohu @ 2022-01-13 12:59:16
@编码落寞 我重新改了一下
by 编码落寞 @ 2022-01-13 13:03:39
@2021xiaohu
测试数据7 2
实际结果应为13
7+(7中6 换3)+(6换3加7中1 换2)+(2 换1)=13
by 2021xiaohu @ 2022-01-13 13:06:00
@编码落寞 知道了谢谢
by 2021xiaohu @ 2022-01-13 13:32:50
@编码落寞
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,k,sum=0,s;
cin>>n>>k;
s=n%k+n/k;
while(s>=k)
{
s=s/k;
sum=sum+s;
}
sum=sum+n+n/k;
cout<<sum<<endl;
return 0;
}
by 2021xiaohu @ 2022-01-13 13:33:48
@编码落寞 还在吗 救救孩子
by 2021xiaohu @ 2022-01-13 13:36:30
@编码落寞 这个7 2输出的是13但是第三个还是过不了
by 编码落寞 @ 2022-01-13 15:01:43
@2021xiaohu
实际3的数据是5 2
每次要换的时候,要看上一步是否还有剩余的