Skip to content

Instantly share code, notes, and snippets.

@AsafFisher
Last active March 9, 2018 16:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsafFisher/9f37c5bebeabea6445929f389e5918e9 to your computer and use it in GitHub Desktop.
Save AsafFisher/9f37c5bebeabea6445929f389e5918e9 to your computer and use it in GitHub Desktop.
import java.util.TreeMap;
public class MyClass {
static TreeMap<Integer, String> a = new TreeMap<Integer, String>();public static void main(String args[]) {a.put(1000, "M");a.put(900, "CM");a.put(500, "D");a.put(400, "CD");a.put(100, "C");a.put(90, "XC");a.put(50, "L");a.put(40, "XL");a.put(10, "X");a.put(9, "IX");a.put(5, "V");a.put(4, "IV");a.put(1, "I");System.out.print(b(44));}static String b(int n){int n1=a.floorKey(n);if(n==n1)return a.get(n);return(a.get(n1) + b(n-n1));}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment