Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Problem 1207

Posted by fforoudian at 2010-12-23 22:44:46
I am trying the following code and it returns correct data running through visual studio express 2008 but it gives me wrong answer in this site.  I am assuming that it has something to do with how I am reading in my numbers.  Does anyone know why

#include <iostream>
#include "stdafx.h"
using namespace std;

int main()
{
   	int i, j, v, count=0, max=0;
	cin >> i >> j;
	for (int n=i; n<=j; n++)
	{
		v=n;
		if (v==1)
		{
			count++;
		}
		else
		{
			do{
				if (v % 2== 0)
				{
					v=v/2;
					count++;
				}
				else 
				{
					v=3*v+1;
					count++;
				}
			}while (v!=1);
		}
		if (count > max)
		{
			max=count;
		}
	}
	cout << i << " " << j << " " << max << "\n";
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator