0
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;
}

/>

2
Contributors
5
Replies
17
Views
2 Years
Discussion Span
Last Post by Reem_1
Featured Replies
  • your answer for 201 210 is 174, should be 89 according to the example input/output in the instructions. Read More

  • 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 … Read More

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???

1

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 by Ancient Dragon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.