今天打毛子的比赛,被打成了狗,来写几个刘汝佳找找自信!
题意就是给你1~n的序列,然后可以同时挑选几个数减去x,问最快几次能减到0.输入是n
题解就是这么回事那个,你看啊,f(5) = 1,2,3,4,5. = f(2) +1 相当于这种情况第三第四第五同时减去3,12012.然后就妥妥的了。
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int f(int n)
{
if(n == 1) return 1;
else return f(n / 2) + 1;
}
int main()
{
int n;
while(~scanf("%d",&n)){
printf("%d\n",f(n));
}
return 0;
}