摘要:
=== 1. and運算 ===( & ) and運算通常用于二進制取位操作,例如一個數 and 1的結果就是取二進制的最末位。這可以用來判斷一個整數的奇偶,二進制的最末位為0表示該數為偶數,最末位為1表示該數為奇數. 相同位的兩個數字都為1,則為1;若有一個不為1,則為0。 00111 11100 (&或者and) ---------------- 00100=== 2. or運算 ===( | ) or運算通常用于二進制特定位上的無條件賦值,例如一個數or 1的結果就是把二進制最末位強行變成1。如果需要把二進制最末位變成0,對這個數or 1之后再減一就可以了,其實際意義就是
閱讀全文
摘要:
DescriptionFarmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B are empty while bucket C is full of milk. Sometimes, FJ pours milk from one bucket to another until the second bucke
閱讀全文
摘要:
DescriptionPalindromes are numbers that read the same forwards as backwards. The number 12321 is a typical palindrome.Given a number base B (2 <= B <= 20 base 10), print all the integers N (1 <= N <= 300 base 10) such that the square of N is palindromic when expressed in base B; also pri
閱讀全文
摘要:
DescriptionConsider the number triangle shown below. Write a program that calculates the highest sumof numbers that can be passed on a route that starts at the top and ends somewhere on the base. Each step can go either diagonally down to the left or diagonally down to the right. 7 3...
閱讀全文