Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Solution {
  5.  
  6.     public static void main(String[] args) {
  7.  
  8.         String pattern = "0123456789ABCDEF";
  9.  
  10.         String input = "";
  11.         Scanner sc = new Scanner(System.in);
  12.         input = sc.nextLine();
  13.  
  14.         int lenghtInput = input.length();
  15.         System.out.println(lenghtInput);
  16.         int lenghtPattern = pattern.length();
  17.  
  18.         int pointer = 0;
  19.         long result = 0;
  20.  
  21.         for (int i = lenghtInput - 1; i >= 0; i--) {
  22.             for (int j = 0; j < lenghtPattern; j++) {
  23.                 if (input.charAt(i) == pattern.charAt(j)) {
  24.                     result += (double) j * Math.pow(16, pointer);
  25.                     pointer++;
  26.                 }
  27.             }
  28.         }
  29.  
  30.         System.out.println(result);
  31.  
  32.     }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement