[TIOJ]1011 . Edit Distance In Numbers

題目:
http://tioj.ck.tp.edu.tw/problems/1011
--------------------------------------------------------------------------------------------
#include<cstdio>
int main()
{
unsigned int a,b;
while(scanf("%u%u",&a,&b)!=EOF)
{
unsigned int ans = 0;
while(a != b)
{
if(a < b)
{
unsigned int t = a;
a = b;
b = t;
}
a /= 2;
ans++;
}
printf("%u\n",ans);
}
return 0;
}

留言

這個網誌中的熱門文章

[ZJ]b513: 判斷質數-商競103

[ZJ]d212: 東東爬階梯