This code works fine and i tested using many other test cases as well and it worked fine for all of them.
Yet still i seem to be getting NZEC error when i submit it.
Any help would be appreciated.Thank you!
import java.util.*;
import java.math.BigInteger;
public class Main
{ public static HashMap<Integer,Long> map= new HashMap<Integer,Long>();
public static void main(String[] args) {
Scanner sc = new Scanner(System.in4);
String s;
s=sc.nextLine();
while(!s.equals(""))
{
int n =Integer.parseInt(s);
System.out.println(maxDollars(n));
s=sc.nextLine();
}
}
public static long maxDollars(int n)
{
if(n<12) return n;
if(map.containsKey(n)) return map.get(n);
long max=maxDollars(n/2)+maxDollars(n/3)+maxDollars(n/4);
map.put(n,max);
return max;
}
}
created
last reply
- 3
replies
- 807
views
- 2
users
- 1
link