article thumbnail image
Published 2021. 6. 8. 17:49
비트단위로 NOT하여 출력
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        System.out.println(~a);
    }
}

 

비트단위로 AND하여 출력
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
       Scanner scan = new Scanner(System.in);
       Long a = scan.nextLong();
       Long b = scan.nextLong();

       System.out.println(a&b);
    }
}

 

비트단위로 OR하여 출력
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
       Scanner scan = new Scanner(System.in);
       Long a = scan.nextLong();
       Long b = scan.nextLong();

       System.out.println(a|b);
    }
}

 

비트단위로 XOR하여 출력
import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
       Scanner scan = new Scanner(System.in);
       Long a = scan.nextLong();
       Long b = scan.nextLong();

       System.out.println(a^b);
    }
}

 

 

 

복사했습니다!