很奇怪啊!!绝对不超时的,求检查:
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
const int MAXA = 2147483647 / 3;
int i = 0;
do
{
i++;
int a, l, count = 1;
scanf("%d%d", &a, &l);
if (a == -1) break;
printf("Case %d: A = %d, limit = %d, ", i, a, l);
while (a > 1)
{
if (a % 2)
if ((a < MAXA) && (a * 3 < l))
{
count++;
a = a * 3 + 1;
}
else
break;
else
{
count++;
a /= 2;
}
}
printf("number of terms = %d\n", count);
}
while (1);
#ifdef DEBUG
const char *dbstr = "\n====== Debug Information ======\nTime Used: %.2lfs\n====== Debug Information ======\n";
printf(dbstr, (double) clock() / CLOCKS_PER_SEC);
system("pause");
#endif
return 0;
}