### my frist ACM solve

problem 100

#include stdio.h

int calc (unsigned long int i, unsigned long int j, unsigned long int f);

int

main (void)

{

unsigned long int i, j, f;

while(scanf ("%lu", &i)==1)

{

if (!(0 < i && i < 1000000))

{

scanf ("%lu", &i);

}

scanf ("%lu", &j);

if (!(0 < j && j < 1000000)) {

scanf ("%lu", &j);

}

printf ("%lu\t %lu\t", i, j);

if (i > j)

{

f = i - j;

f = f + 1;

}

else

{

f = j - i;

f = f + 1;

}

calc (i, j, f);

}

return 0;

}

int calc (unsigned long int i, unsigned long int j, unsigned long int f)

{

unsigned long int m, k = 1, n = 0;

unsigned long int l[f];

unsigned long int p;

if (i > j)

{

p = i - j;

p = p + 1;

for (; j <= i; j++)

{

for (m = j; m > 1;)

{

if (m % 2 == 0)

m = m / 2;

else

m = 3 * m + 1;

k = k + 1;

}

l[n] = k;

n = n + 1;

k = 1;

}

}

else

{

p = j - i;

p = p + 1;

for (; i <= j; i++)

{

for (m = i; m > 1;)

{

if (m % 2 == 0)

m = m / 2;

else

m = 3 * m + 1;

k = k + 1;

}

l[n] = k;

n = n + 1;

k = 1;

}

}

p = p-1;

for (n = 0; n < p; n++)

{

if (l[n] > l[n + 1])

{

l[n + 1] = l[n];

}

}

printf ("%lu\n", l[p]);

}

## 1 comment:

While you read this, YOU start to BECOME aware of your surroundings, CERTIAN things that you were not aware of such as the temperature of the room, and sounds may make YOU realize you WANT a real college degree.

Call this number now, (413) 208-3069

Get an unexplained feeling of joy, Make it last longer by getting your COLLEGE DEGREE. Just as sure as the sun is coming up tomorrow, these College Degree's come complete with transcripts, and are VERIFIABLE.

You know THAT Corporate America takes advantage of loopholes in the system. ITS now YOUR turn to take advantage of this specific opportunity, Take a second, Get a BETTER FEELING of joy and a better future BY CALLING this number 24 hours a day.

(413) 208-3069

Post a Comment