The integers i and j must appear in the output in the same order in which they appeared in the input
your code doesnt do it because you swap the two integers. it prints i and j in non decreasing order for each case.
Yeah, this caught me, too. Made me learn to read and reread the problems before submitting, but there are still some evil ones out there that assume you're doing very strict management of the input, which is annoying.
i think you are "xtremely" new!! when there is a sticky about any problem then creating a new thread is a kind of crime..besides you should read all the previous posts before posting a new one.if you want to find previous posts go to the search option.
and for this problem just look at the top of this volume.there's a huge no. of discussions waiting to help you!!!
why it isWA?
#include<iostream>
using namespace std;
long int fun(long int n,long int i)
{
if(n==1)return i;
if(n%2==0)
return fun(n/2,i+1);
else return fun(3*n+1,i+1);
}
int main()
{
long int a,b;
int max=1;
while(cin>>a>>b)
{
if(a>b){
long int temp;
temp=a;
a=b;
b=temp;
}
for(int i=a;i<=b;++i)
{
long int j;
j=fun(i,1);
if(max<j)max=j;
}
cout<<a<<" "<<b<<" "<<max<<endl;
}
return 0;
Hello everybody,
Do you know what version of Java is supported by the robot? In the problem 100, I use String.split() method and it always complain "Compile error", but when I change to use StringTokenizer class instead, I get "Accepted".