• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem in UVA  RSS feed

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've recently started in UVA website and i can't find why it doesn't accept my code
this is the link of the problem :
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=36
and this is my code:
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
Scanner input = new Scanner(System.in);
while (input.hasNext()) {

long i = input.nextLong();
long j = input.nextLong();
int maxCount = 0;
int count;
long n;
for (long j2 = i; j2 <= j; j2++) {
count = 0;
n = j2;
while (n != 1) {
if (n % 2 != 0) {
n = 3 * n + 1;
} else {
n = n / 2;
}
count++;
}
count++;
if (count >= maxCount) {
maxCount = count;
}

}

System.out.println(i+" "+j+" "+maxCount);
}
}

}
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does this have to do with Android (which this forum is all about) ?

you should also post what the actual problem is. Folks here are unlikely to know what the UVA web site is or does, and what, exactly, you mean by "it doesn't accept my code".
 
No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!