链接上给出了编写程序目的的详细信息:https ://www.codechef.com/problems/COOKMACH/
和错误
超过时间限制
Sub-Task Task # Score Result (time)
1 0 NA AC (0.000000)
1 1 NA TLE (1.010000)
1 2 NA TLE (1.010000)
1 3 NA TLE (1.010000)
Final Score -> 0.000000 Result - TLE
2 4 NA TLE (1.010000)
2 5 NA TLE (1.010000)
2 6 NA TLE (1.010000)
7 NA WA (0.000000)
最终分数 - 0.000000 结果 - TLE
代码是
#include <stdio.h>
int main(void)
{
int test, set, des, a = 1, ctr = 0, str = 0, x;
scanf("%d", &test);
if (test > 0 && test <= 200)
{
for (x = 0; x < test; x++)
{
ctr = 0;
scanf("%d", &set);
scanf(" %d\n", &des);
if ((set > 0 && set <= 10000000) && (des > 0 && des <= 10000000))
{
if (set <= 100 && des <= 100)
{
if (set == des)
ctr = 0;
if (set == 1)
{
while (set != des)
{
set = set * 2;
ctr++;
}
}
else if (set != 1)
{
if (des % 2 == 0)
{
while (a < des)
{
a = a * 2;
str++;
}
}
if (a == des || des == 1)
{
if (set < des)
{
if (set % 2 == 0)
{
while (set != des)
{
set = set * 2;
ctr++;
}
}
else if (set % 2 == 1)
{
set = (set - 1) / 2;
ctr++;
while (set != des)
{
set = set * 2;
ctr++;
}
}
}
if (set > des)
{
if (set % 2 == 0)
{
while (set != des)
{
set = set / 2;
ctr++;
}
}
else if (set % 2 == 1)
{
set = (set - 1) / 2;
ctr++;
while (set != des)
{
set = set / 2;
ctr++;
}
}
}
}
}
}
printf("%d\n", ctr);
}
}
return 0;
}
}