Not a new one:
Input N, being n, 0 ≤ n ≤ 5.
Output N times "Hello World."
Example:
Input
3
Output
Hello World.
Hello World.
Hello World.
These 2 are my best solutions:
First
public class Out
{
public static void main(String[] a) throws Exception
{
java.io.OutputStream o = System.out;
byte n = Byte.parseByte(new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine());
for(byte i = 0;i<n;i++){
o.write("Hola mundo.\n".getBytes());
}
}
}
Second
public class Out
{
public static void main(String[] a) throws Exception{
byte n = Byte.parseByte(new java.io.BufferedReader(new java.io.InputStreamReader(System.in)).readLine());
while(n>0){switch(n){case 0: w();break;case 1: w();break;case 2: w();break;case 3: w();break;case 4: w();break;case 5: w();break;}n--;}
}
static void w() throws Exception{
System.out.write("Hola mundo.\n".getBytes());
}
}
According to the server it is being tested on ( im not an owner of that server), first attempt gives me 0.006ms and 622 KiB while second attempt gives me same time with 625 KiB.
I am not able to provide the Java version being used but if you want, feel free to use the main site ( spanish language ) https://www.aceptaelreto.com/problem/statement.php?id=116
P.S.: Some peoeple were able to get it on 0.005ms and 88KiB.
edit: -this code is being benchmarked on the link used before. -The point is to get the fastest code ( and if possible, with the least amount of memory used), not the shortest one.
Apparently Im not able to use comments since I do not have the required reputation score.