• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to execute the Java program to 0 sec?  RSS feed

 
yani pray
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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...
 
prem pillai
Ranch Hand
Posts: 87
Java Opera
  • Mark post as helpful
  • send pies
  • 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.
 
Campbell Ritchie
Marshal
Posts: 56578
172
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!