Nyoj 744 ant's problem (I), nyoj744 ant's Problem

Source: Internet
Author: User

Nyoj 744 ant's problem (I), nyoj744 ant's Problem
Ant's problem (I) time limit: 1000 MS | memory limit: 65535 KB difficulty: 2

Description

Little ant shoes recently fell in love with bit operations, and he felt that bit operations were amazing. However, he encountered a problem recently:

Given a range [a, B], we can look for two numbers x and y in the range to make x exclusive or y the largest. Come on, help him!

Input
There are multiple groups of test data (ended with EOF ).
Enter two numbers a and B for each group of data (0 <= a <B <2 ^ 63)
Output
Outputs An exclusive or maximum value between a and B.
Sample Input
1 28 9
Sample output
31

Ideas:

Multiple Data tests show that each output result is 2 ^ n-1, and the relationship between n and a and B is required. This topic guides us to use bitwise operations,

Take the number of two groups, for example, 4 or 8. The calculated range is 7 ^ 8 = 15 = (1111) 2 = 2 ^ 4-1;
Search for a group of 2, 6 at will, and calculate the range of 2 ^ 5 = 7 = (111) 2 = 2 ^ 3-1;

Through the above analysis, we can know that the maximum value is 2 ^ n-1, and n is the binary number of The number of right boundary.

Therefore, you can think of the following code:

# Include <stdio. h> int main () {long a, B, x; // use the long type while (~ Scanf ("% lld", & a, & B) {x = a ^ B; // find the number of digits int cnt = 0; while (x) ++ cnt, x> = 1; // calculate the number of digits of printf ("% lld \ n", (1LL) <cnt)-1 ); // obtain 2 ^ cnt-1;} return 0 ;}




Hello, there is another problem. The bandwidth limit is 744.

It's okay to tell you how many devices you have. The time is counted from when you open your vro. So you remember that when you finish the network-off Route, your cat will remember to lose power. Otherwise, two devices will work together. it's time for you to enable automatic dial-up on the router.

A Mathematical Problem

Number of times the loan balance should be paid back to the principal
0 1 20000.0
1 479.63 41.50 521.13 119,520.37
2 479.79 41.33 521.13 119,040.58
3 479.96 41.17 521.13 118,560.62
4 480.13 41.00 521.13 118,080.49
5 480.29 40.84 521.13 117,600.20
6 480.46 40.67 521.13 117,119.74
7 480.62 40.50 521.13 116,639.12
8 480.79 40.34 521.13 116,158.33
9 480.96 40.17 521.13 115,677.37
10 481.12 40.01 521.13 115,196.25
11 481.29 39.84 521.13 114,714.96
12 481.46 39.67 521.13 114,233.50
13 481.62 39.51 521.13 113,751.88
14 481.79 39.34 521.13 113,270.09
15 481.96 39.17 521.13 112,788.14
16 482.12 39.01 521.13 112,306.01
17 482.29 38.84 521.13 111,823.72
18 482.46 38.67 521.13 111,341.27
19 482.62 38.51 521.13 110,858.65
20 482.79 38.34 521.13 110,375.86
21 482.96 38.17 521.13 109,892.90
22 483.12 38.00 521.13 109,409.78
23 483.29 37.84 521.13 108,926.49
24 483.46 37.67 521.13 108,443.03
25 483.62 37.50 521.13 107,959.40
26 483.79 37.34 521.13 107,475.61
27 483.96 37.17 521.13 106,991.65
28 484.13 37.00 521.13 106,507.53
29 484.29 36.83 521.13 106,023.23
30 484.46 36.67 521.13 105,538.77
31 484.63 36.50 521.13 105,054.14
32 484.80 36.33 521.13 104,569.34
33 484.96 36.16 521.13 104,084.38
34 485.13 36.00 521.13 103,599.25
35 485.30 35.83 521.13 103,113.95
36 485.47 35.66 521.13 102,628.48
37 485.64 35.49 521.13 102,142.84
38 485.80 35.32 521.13 101,657.04
39 485.97 35.16 521.13 101,171.07
40 486.14 34.99 521.13 100,684.93
41 486.31 34.82 521.13 100,198.62
42 486.48 34.65 521.13 99,712.14
43 ...... remaining full text>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.