XianYuzhinan @ 2024-05-08 18:41:13
#include<stdio.h>
int main()
{
int n, k, a = 0, sum = 0;
scanf("%d%d", &n, &k);
while (n > 0)
{
--n;
++a;
if (a == k)
{
a -= 3;
n += 1;
}
sum++;
}
printf("%d", sum);
return 0;
}
by kongyanxiang @ 2024-05-08 19:14:40
@XianYuzhinan 判断里面你减3干什么??
by kongyanxiang @ 2024-05-08 19:15:30
@XianYuzhinan 改成
by LHM_zs @ 2024-05-08 19:46:22
将12行的
#include<stdio.h>
int main()
{
int n,k,a=0,sum=0;
scanf("%d%d",&n,&k);
while(n>0)
{
--n;
++a;
if(a==k)
{
a=0;//改这里
n++;
}
sum++;
}
printf("%d", sum);
return 0;
}