Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7521625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:16:52+00:00 2026-05-30T02:16:52+00:00

I am getting runtime errors for my Java solutions to UVa Online Judge problems.

  • 0

I am getting runtime errors for my Java solutions to UVa Online Judge problems. I have finished Problem 100 and it works on my end. Any ideas what could be causing the problem?

import java.util.ArrayList;
import java.util.Hashtable;
import java.util.Scanner;

class P100 {

    public static void main(String args[]) {
        Hashtable<Integer, Integer> solutions = new Hashtable<Integer, Integer>();
        Scanner input = new Scanner(System.in);

        while (input.hasNextInt()) {
            int lowerBound = input.nextInt();
            int upperBound = input.nextInt();

            int longestCount = 0;

            for (int i = lowerBound; i <= upperBound; i++) {
                int n = i;
                int count = 1;

                ArrayList<Integer> sequence = new ArrayList<Integer>();

                while (n != 1) {
                    if (solutions.containsKey(n)) {
                        count += solutions.get(n) - 1;
                        break;
                    }

                    sequence.add(n);

                    count += 1;
                    if (n % 2 == 0) n /= 2;
                    else n = 3 * n + 1;
                }

                for (int j = 0; j < sequence.size(); j++) {
                    solutions.put(sequence.get(j), count - j);
                }

                if (count > longestCount) longestCount = count;

                solutions.put(i, count);
            }

            System.out.printf("%d %d %d\n", lowerBound, upperBound, longestCount);
        }
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T02:16:53+00:00Added an answer on May 30, 2026 at 2:16 am

    You need to rename

    class P100
    

    to

    public class Main
    

    when you copy the code into UVa or it will tell you that the class Main was not found. This is so the judge can run your code (because java needs to know the class name). I myself forget to do this sometimes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Java program that executes Runtime.getRuntime().exec(ls -l); many times, once for each
I'm getting the error Error for /la/truckpage java.lang.NoClassDefFoundError: Could not initialize class com.google.apphosting.runtime.security.shared.stub.java.net.Proxy For
I've been looking up ways to run external programs using Java's runtime. This works
I'm trying to launch VB application from Java, but I'm getting runtime error: Exception
I am getting the runtime error Exception in thread main java.lang.ClassCastException: m.compiler.datatypes.Int cannot be
I am getting this weird RunTime error. The classes compile easy on eclipse but
I am getting the following error: Microsoft JScript runtime error: 'Sys' is undefined While
I'm getting the error Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Error executing child request for
I am getting a Microsoft JScript runtime error: 'Sys' is undefined error on one
I'm getting a java.lang.ClassNotFoundException: javax.ejb.EJBObject error when I'm running my application as a JAR

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.