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

  • Home
  • SEARCH
  • 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 8008703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:13:14+00:00 2026-06-04T18:13:14+00:00

Source code: import java.util.Arrays; class Uglynumbers { /** * @param arg */ public static

  • 0

Source code:

import java.util.Arrays;


class Uglynumbers {

/**
 * @param arg
 */
public static void main(String[] args) {
    // TODO Auto-generated method stub
    long[] ugly= new long[1510];
    long inter1,inter2,inter3;
    int count=0;
    boolean found1=false,found2=false,found3=false;

    ugly[0]=1;
    ugly[1]=2;
    ugly[2]=3;
    ugly[3]=5;
    count=4;
    for (int i=1; i<1500;i++)
    {
        found1=found2=found3=false;
        inter1= ugly[i]*2;
        inter2= ugly[i]*3;
        inter3= ugly[i]*5;

        for(int z=count-1;z>=0;z--)
        {
            if((inter1>ugly[z]) && (inter2>ugly[z]) && (inter3>ugly[z]))
                break;
            else
            {
             if(ugly[z]==inter1)
                found1=true;
             if(ugly[z]==inter2)
                found2=true;
             if(ugly[z]==inter3)
                found3=true;
            }

            if( found1 && found2 && found3)
                break;
        }

        if(!found1)
        {

            ugly[count]=inter1;
            count+=1;

        }

        if(!found2)
        {

            ugly[count]=inter2;
            count+=1;

        }

        if(!found3)
        {

            ugly[count]=inter3;
            count+=1;

        }

        Arrays.sort(ugly,0,count);


        if(count>=1500)
            break;

        }


System.out.println("The 1500'th ugly number is "+ ugly[1499]);


System.exit(0);


}

};

When I run this code in eclipse its working fine. But when i give it UVA online judge, am getting following run time error: “”136 – Ugly Numbers has failed with verdict Runtime error.
This means that the execution of your program didn’t finish properly. Remember to always terminate your code with the exit code 0″.”

What am missing in the code?

  • 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-06-04T18:13:17+00:00Added an answer on June 4, 2026 at 6:13 pm

    It seems that it requires the class to be called Main.

    http://code.google.com/p/collatz-deandalm/issues/detail?id=13

    EDIT:

    Entire Java specification:

    http://uva.onlinejudge.org/index.php?option=com_content&task=view&id=15&Itemid=30

    Java Specifications:
    The Java programs submitted must be in a single source code (not .class) file. Nevertheless, you can add as many classes as you need in this file. All the classes in this file must not be within any package.

    All programs must begin in a static main method in a Main class.

    Do not use public classes: even Main must be non public to avoid compile error.

    Use buffered I/O to avoid time limit exceeded due to excesive flushing.

    As a reference, we provide a sample Java code

    Get rid of this:

    System.exit(0);

    And change Uglynumbers to Main.

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

Sidebar

Related Questions

Given the following code : import java.io.*; public class Main { public static void
Source Code of LoginAction.java package com.test; import java.util.ArrayList; import java.util.List; public class LoginAction {
this is the code: import java.awt.*; import java.awt.event.*; import java.applet.*; import java.util.Vector; public class
I have this Code... ifsDAO.java package source; import java.sql.*; import java.sql.SQLException; import java.util.*; public
Hi Deployed the following code in eclipse //import cs1.Keyboard; import java.util.*; import java.io.*; public
Superclass source code public class Date { private int month; private int day; private
So here is my source code : import com.jaspersoft.mongodb.MongoDbConnection; import com.jaspersoft.mongodb.MongoDbDataSource; import java.io.File; import
I have a particular file that Java says is empty... Source Code import java.io.File;
What is wrong with this source code? 1 package Core; 2 3 import java.sql.*;
I have seen in some source code (by other developers) something like this: #import

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.