Advertisement
STANAANDREY

ac labs 2

Mar 8th, 2023
863
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.HashMap;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         int bitmap=0xA3490208;
  6.         String binStr = Integer.toBinaryString(bitmap);
  7.         int size = 0;
  8.         for (int i = 1; i <= binStr.length(); i++) {
  9.             if (binStr.charAt(i - 1) == '0') {
  10.                 continue;
  11.             }
  12.  
  13.             if (i == 1) {
  14.                 size += 16;
  15.             } else if (i == 2) {
  16.                 size += 6;
  17.             } else if(i == 3) {
  18.                 size += 12;
  19.             } else if (4 <= i && i <= 11) {
  20.                 size += 8;
  21.             } else if (12 <= i && i <= 32) {
  22.                 size += 4;
  23.             }
  24.         }//*/
  25.         System.out.println(size+" bytes");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement