憨憨的我写的(4个变量)
#include<stdio.h>
int main()
{
int sum = 0;//共喝了几瓶
int count;//当前有几瓶可以喝
scanf("%d",&count);
int mai = count % 2;//没有被凑一对卖掉的瓶数
int sheng = 0;//喝完后剩下几个空瓶
while ( count > 0 )
{
sum = sum + count;
sheng = count + mai;
count = sheng / 2;
mai = sheng % 2;
}
printf("%d", sum);
return 0;
}
标准答案1 (2个变量)
#include<stdio.h>
int main()
{
int total = 0;//喝了多少瓶
scanf("%d", &total);
int empty = total;//喝完剩下几个空瓶子
while (empty>1)
{
total = total + empty / 2;
empty = empty / 2 + empty % 2;
}
printf("%d", total);
return 0;
}
标准答案2(1个变量)
int main()
{
int total = 0;
scanf("%d", &total);
if(total != 0)
{
total = total*2-1;//等差数列
}
printf("%d", total);
return 0;
}