two buttens

 链接 :http://codeforces.com/contest/520/problem/B

 

 

code forces   two buttens代码

*********************

#include <stdio.h>
int main(){
 int s,g,r=0;
 scanf("%d%d",&s,&g);
 for(;s<g;r++){
  if(g%2)g++;
  else g/=2;
 }
 printf("%d\n",r+s-g);
 return 0;
}

我做那天写了快一百行,看了这才知道自己是的问题,我咋老记不住条件弱化呢。

posted @ 2015-03-20 21:03  do+better  阅读(192)  评论(0编辑  收藏  举报