• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 79177
377
  • 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?
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic