I tried all possible test cases and It outputed the correct answer , I wonder why UVA doesn't accept my answer
<#include<iostream>
#include <stdio.h>
using namespace std;
int main()
{
    int i, j;
    unsigned long long int tempI, tempJ;
    int maxCaseLen = 1;
    int count = 1;
    while (scanf("%d %d", &i, &j) == 2)
    {
        if (i>j)
        {
            tempI = j;
            tempJ = i;
        }
        else
        {
            tempI = i;
            tempJ = j;
        }
        int iTemp = tempI;
        while (iTemp <= tempJ)
        {
            unsigned long long int n = iTemp;
            while (n != 1)
            {
                if (n % 2 == 1)
                {
                    n = 3 * n + 1;
                }
                else
                {
                    n = n / 2;
                }
                count++;
            }
            if (maxCaseLen < count)
            {
                maxCaseLen = count;
                count = 1;
            }

            else
                count = 1;
            iTemp++;
        }
        printf("%d %d %d", i, j, maxCaseLen);
    }
    return 0;
}

/>

wonder why UVA doesn't accept my answer

How are we supposed to know that? You didn't even tell us what that program is supposed to do. And what is UVA? My guess University of Virginia???

Your program appears to be retaining one of the last answers

1 10
1 10 20
100 200
100 200 125
201 210
201 210 125
900 1000
900 1000 174

The problem is that you need to reset maxCaseLen back to 1 after the scanf(), between lines 12 and 13.

Edited 2 Years Ago by Ancient Dragon

This question has already been answered. Start a new discussion instead.