PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000193. Mặt nạ bit tối ưu (Bit Mask)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Mặt nạ bit tối ưu (Bit Mask)
Bit Mask
Source: UVa
Version: Phuoc Hung OJ (single-case adaptation where applicable)
Problem Statement
Given three unsigned 32-bit integers with , choose that maximizes the bitwise OR . Among masks attaining the maximum OR, choose the smallest .
Input
The single line contains in this order. This is a single-instance adaptation; do not read until EOF.
Output
Print the smallest optimal .
Subtasks
- Subtask 1 (20 points): ; (unsigned 32-bit).
- Subtask 2 (30 points): ; (unsigned 32-bit).
- Subtask 3 (50 points): ; (unsigned 32-bit).
Examples
Example 1
Input
100 50 60
Output
59
Explanation
The mask 59 yields 100 OR 59 = 127 and is the smallest mask within the interval achieving this maximum.
Example 2
Input
100 50 50
Output
50
Explanation
The range contains only 50, so the answer must be 50.