给大家推荐个靠谱的公众号程序员探索之路,大家一起加油
#include <stdio.h>
int main()
{
int k, n, t;
while (scanf("%d %d", &n, &k) != EOF)
{
if (n<=k&&n!= 0)
{
t=2;
}
else //n个烧饼,总共要翻2*n次,转化到数学面上,为2*n中有几个k, 若有余数,余数化为1
{
if((n*2)%k== 0)
{
t=(2*n)/k;
}
else
{
t=(2*n)/k+1;
}
}
printf("%d\n",t);
}
return 0;
}