Advertisement
Spidey2182

XOR - SUM O(m) (Java)

Jul 5th, 2023 (edited)
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class TestClass {
  4.     public static void main(String args[] ) throws Exception {
  5.         Scanner sc = new Scanner(System.in);
  6.         int m = sc.nextInt();
  7.         int n = sc.nextInt();
  8.  
  9.         for(int i = 0; i <= m; i++) {
  10.             if((i ^ (m - i)) == n) {
  11.                 System.out.println(1);
  12.                 return;
  13.             }
  14.         }
  15.  
  16.         System.out.println(0);
  17.     }
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement