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 8847571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:13:19+00:00 2026-06-14T12:13:19+00:00

I have exercise below: The Lavin Interactive Company, which has developed the turn-based strategy

  • 0

I have exercise below:

The Lavin Interactive Company, which has developed the turn-based
strategy Losers-V, is constantly extending its target market by
localizing the game to as many languages as it can. In particular,
they are interested in creating a version of the game in Anindilyakwa,
which is one of the languages spoken by indigenous Australians.
However, the localization is complicated by the fact that Anindilyakwa
has no numerals. How can a phrase such as “You have seven black
dragons and your enemy has forty black dragons” be translated into
this language? The localizers have decided to translate it as follows:
“You have few black dragons and your enemy has lots of black dragons.”
They have compiled a table showing the rule of replacing numbers of
monsters by Anindilyakwa words.

And my implementation below:

import java.util.Scanner;

public class Localization {

    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);
        int number;
        String designation;

        number = s.nextInt();

        if (number >= 1 && number <= 4) {
        designation = "few";
        }else if(number >= 5 && number <= 9){
            designation = "several";
        }else if(number >= 10 && number <= 19){
            designation = "pack";
        }else if(number >= 20 && number <= 49) {
            designation = "lots";
        }else if(number >= 50 && number <= 99){
            designation = "horde";
        }else if(number >= 100 && number <= 249){
            designation = "throng";
        }else if(number >= 250 && number <= 499){
            designation = "swarm";
        }else if(number >= 500 && number <= 999){
            designation = "zounds";
        }else{
            designation = "legion";
        }
        System.out.println(designation);

    }
}

I loaded my code on competition server. And I see next statistics:

Execution time: 0.109

Memory used: 1 434 KB

After this I checked top level results and what I saw:

Rank 1:

Execution time: 0.062

Memory used: 78 KB

Conclusion:

my code two times slower;
my code is used 20 times more memory.

My question: How? How? How is it possible? Why is my code so stupid?
What do I need change to improve my 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-14T12:13:20+00:00Added an answer on June 14, 2026 at 12:13 pm

    I got it down to 370 KB, 0.78 sec with this code. Kinda bored to get it further…

    import java.io.IOException;
    
    public class Localization {
        public static void main (String[] args) {
            short s = 0;
            while (true) {
                int next = 0;
                try {
                    next = System.in.read();
                } catch (IOException e) {
    
                }
                if (next < '0' || next > '9') break;
    
                s = (short) (s * 10);
                s = (short) (s + ((short) (next - '0')));
            }
    
            if (s >= 100) {
                if (s >= 500) {
                    if (s >= 1000) {
                        System.out.print('l');
                        System.out.print('e');
                        System.out.print('g');
                        System.out.print('i');
                        System.out.print('o');
                        System.out.print('n');
                    } else {
                        System.out.print('z');
                        System.out.print('o');
                        System.out.print('u');
                        System.out.print('n');
                        System.out.print('d');
                        System.out.print('s');
                    }
                } else {
                    if (s >= 250) {
                        System.out.print('s');
                        System.out.print('w');
                        System.out.print('a');
                        System.out.print('r');
                        System.out.print('m');
                    } else {
                        System.out.print('t');
                        System.out.print('h');
                        System.out.print('r');
                        System.out.print('o');
                        System.out.print('n');
                        System.out.print('g');
                    }
                }
            } else {
                if (s >= 10) {
                    if (s >= 50) {
                        System.out.print('h');
                        System.out.print('o');
                        System.out.print('r');
                        System.out.print('d');
                        System.out.print('e');
                    } else if (s >= 20) {
                        System.out.print('l');
                        System.out.print('o');
                        System.out.print('t');
                        System.out.print('s');
                    } else {
                        System.out.print('p');
                        System.out.print('a');
                        System.out.print('c');
                        System.out.print('k');
                    }
                } else {
                    if (s >= 5) {
                        System.out.print('s');
                        System.out.print('e');
                        System.out.print('v');
                        System.out.print('e');
                        System.out.print('r');
                        System.out.print('a');
                        System.out.print('l');
                    } else {
                        System.out.print('f');
                        System.out.print('e');
                        System.out.print('w');
                    }
                }
            }
    
            System.out.println();
            System.out.flush();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code like this, which is solved by me following a exercise
I have a code snippet below from an exercise I'm working on. It reads
I have a text file input which contains data as below. How can I
I have the exercise with following code int FindFirstSet(unsigned BitMap, unsigned start) { unsigned
I have a simple exercise where I call a Thread and subsequently the run()
During my university exercise I have come across strange behaviour of a variable. /*
I have been given an exercise to solve the zebra puzzle using a constraint
I have been busy with a exercise where I need to compare a winning
i have to crawl last.fm for users (university exercise). I'm new to python and
Let's say I have a large query (for the purposes of this exercise say

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.