This week's book giveaway is in the Testing forum.
We're giving away four copies of Data Structures the Fun Way: An Amusing Adventure with Coffee-Filled Examples and have Jeremy Kubica on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

how to execute the Java program to 0 sec?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I try this problem http://www.z-trening.com/tasks.php?show_task=5000000001
the problem very simple, but i don't understand i can't execute java with 0 sec,, anybody know how to very fast execute in java or how implements method can be used??

problem :
From the standard input read two numbers M and N, 0<=M,N<=200. Output the sum of M and N to the standard output.

Time: 0.1 sec.
Memory: 1 MB
Tests: 3

sorry i'm beginning java i hope you give suggest or give me solustion...
 
Ranch Hand
Posts: 87
Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i can't execute java with 0 sec



Ok ; have you tried coding it and then measuring the time its taking?
Do you know how to measure the time taken by your program? Have a look at java.lang.System class's java doc and find methods you can use to measure time and let us know your findings.
 
Marshal
Posts: 76842
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a limit to how quickly you can execute such a program because a print statement takes an appreciable time. I got it down to 0.001s by taking both the numbers as command-line arguments. You need to find out what the precision of the website you quoted; does it work to the nearest 0.1s or something?
 
30 seconds to difuse a loaf of bread ... here, use this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic