Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package hexadec;
- public class Hexadec
- {
- public static final long MAX = 16;
- public static void main(String [] args)
- {
- System.out.println(Long.toHexString(GetPermutes(0, 0, 0, 0)).toUpperCase());
- }
- public static long GetPermutes(int spos, int acount, int bcount, int ccount)
- {
- long total = 0;
- if (acount >= 1 && bcount >= 1 && ccount >= 1)
- {
- long a = (MAX-spos);
- long c = (long)Math.pow(13, (MAX-a) - (acount + bcount + ccount));
- long t = 0;
- for (int i = 0; i <= a; i++)
- t += (long)Math.pow(16, i)*c;
- return t;
- }
- if (spos == MAX) return 0;
- for (int i = 0; i < 4; i++)
- {
- if (spos == 0 && i == 0) continue;
- if (i == 0) {
- total += GetPermutes(spos+1, acount+1, bcount, ccount);
- } else if (i == 2) {
- total += GetPermutes(spos+1, acount, bcount+1, ccount);
- } else if (i == 3) {
- total += GetPermutes(spos+1, acount, bcount, ccount+1);
- } else {
- total += GetPermutes(spos+1, acount, bcount, ccount);
- }
- }
- return total;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement