hyperboli @ 2024-10-13 15:37:17
#include<stdio.h>
int main(){
int n,k;
int j;
scanf("%d%d",&n,&k);
j=n/k;
if(j>=k){
j+=j/k;
}
n=n+j;
printf("%d",n);
return 0;
}
by caomuyilin @ 2024-10-13 15:43:13
可以兑换多次,不止一次的。
by Asuka_Langley_Soryu @ 2024-10-13 15:45:33
最后一根烟也会产生烟蒂,但无法兑换
by hyperboli @ 2024-10-13 16:34:11
#include<stdio.h>
int main(){
int n,j,k;
int sum;
scanf("%d %d",&n,&k);
while(n>0){
n--;
j++;
if(j%k==0){
n++;
}
}
printf("%d\n",j);
return 0;
}
这是我改的,不知道为啥一直在转圈,也不显示通没通过
by hyperboli @ 2024-10-13 16:34:45
@caomuyilin 这回呢,大哥
by hyperboli @ 2024-10-13 16:35:01
@Asuka_Langley_Soryu 大哥,这回呢
by caomuyilin @ 2024-10-13 17:19:10
你这变量也不初始化,6.
by caomuyilin @ 2024-10-13 17:22:28
int n, k, sum=0;
cin >> n >> k;
sum = n;
while (n >= k)
{
int rad = n % k; // 获取剩余的
n /= k; // 替换的
sum += n; // 累计
n += rad; // 更新 n
}
cout << sum << endl;
当思路比较混乱的时候就把步骤分解下