Page 9 of 14

Posted: Tue Aug 15, 2006 4:34 pm
by sohel
hello-

when printing:
Between x and y, a generates the longest sequence of b values.

you have to make sure x <= y.

so for input:
20 1

output should be:
Between 1 and 20, 18 generates the longest sequence of 20 values.

and not:
Between 20 and 1, 18 generates the longest sequence of 20 values.

hope it helps.

BTW: other threads already exists about this problem. I assume you are new in this forum... you can search for a particular problem by using the 'search' option. If you don't get the required help, then make a post in that thread.

Posted: Tue Aug 15, 2006 5:10 pm
by Iffat
thanx a lot.... :) :) :) :) :) i get AC :) :) :)

371 why wa

Posted: Tue Sep 12, 2006 12:47 pm
by sobuz
#include<stdio.h>
int main()
{
unsigned long int n,i,count=0,j,k,large=0,w;
do
{
scanf("%lu %lu",&n,&k);
if(n==0&&k==0)
exit(1);
for(j=n;j<=k;j++)
{
i=j;
do
{
if(i%2!=0)
i=3*i+1;
else
i=i/2;
count++;

}while(i!=1);

if(large<count){
w=j;
large=count;
}
count=0;
}


printf("Between %lu and %lu, %lu generates the longest sequence of %lu values.\n",n,k,w,large);

large=0;
}while(n!=0&&k!=0);
return 0;
}

Posted: Mon Oct 30, 2006 1:11 pm
by emotional blind
First number may be greater than Second one in some pair... so consider it..
Just insert This line after scanf()

Code: Select all

if(n>k){i=n;n=k;k=i;}
And you will get Accepted.
After getting Accepted, Please dont forget to remove your code.
Keep Posting.

Posted: Wed Nov 15, 2006 4:39 pm
by albet_januar
can anybody help me to do check my code..??
why it can get WA..

Code: Select all

deleted after acc.. 
}
thx :D

Posted: Wed Nov 15, 2006 6:04 pm
by Jan
Suppose you are told to print 'abc', if you print 'cba' or 'bca' then you will get WA.

Posted: Wed Nov 15, 2006 6:18 pm
by albet_januar
4 jan :
i don't really understand with ur explanation.. bcos im not good in english..
can u give a clearer explanation?

thx b4

Posted: Wed Nov 15, 2006 6:26 pm
by Jan
You are not printing correctly. Your code doesnot even pass the sample. Just match both outputs carefully and you will find your error.

Posted: Thu Nov 16, 2006 12:16 pm
by albet_januar
albet_januar wrote:can anybody help me to do check my code..??
why it can get WA..

Code: Select all

deleted after ACC..
thx
:D

Posted: Sat Feb 10, 2007 3:20 pm
by newton

Code: Select all


   Accepted so deleted 









thanks.

Posted: Sat Feb 10, 2007 4:11 pm
by rio
The largest value in the sequence will not be larger than can be accomodated in a 32-bit Pascal LongInt or C long
The "sequence" means the numbers between L and H.
It doesn't say that i * 3 + 1 fits in long.

After fixing this point, you will get WA.
There are some point to fix in your code.

Posted: Tue Feb 20, 2007 3:26 pm
by newton
hmm

Code: Select all

                    but if it is 00.627 sec?











newton................................ simply the best

371Wa ~~~~ Help ~~~~

Posted: Fri Mar 30, 2007 1:29 pm
by lena
#include<stdio.h>
#include<iostream>
using namespace std;
long long int l,h;
long long ark(long long x)
{
unsigned long long a=x;
long long res = 0;
while(a!=1)
{
res++;
if(a%2==0)a/=2;
else a= 3*a+1;
}
return res;
}
int main()
{
while(cin>>l>>h,l!=0 || h!=0)
{
long long i;
if(l>h){i =l;l = h;h= i;}
if(l<=0)break;
long long res = ark(l);
long long resp = l;
long long t;
for(i=l+1;i<=h;i++)
{
t = ark(i);
if(t>res)
{
res = t;
resp = i;
}
}
printf("Between %lld and %lld, %lld generates the longest sequence of %lld values.\n",l,h,resp,res);
}
return 0;
}

Posted: Fri Mar 30, 2007 2:42 pm
by helloneo
Don't create a new thread if there is one already..
Use this one..
http://online-judge.uva.es/board/viewtopic.php?t=2814

information On 371

Posted: Fri Mar 30, 2007 6:01 pm
by lena
1.when n =1,the value is 3,not 1.....
2.the input and output is in the range of long,but the sequence may out of it.