[ACM] hdu 3555 Bomb (Digital DP, count the total number of "49" contained in 1-N)
BombTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission (s): 7187 Accepted Submission (s): 2512
Problem DescriptionThe counter-terrorists found a time bomb in the dust. but this time the terrorists improve on the time bomb. the number
Problem Description:
Given a decimal integer n, the number of "1" occurrences in all integers from 1 to n is calculated.
For example: n=2,1,2 appeared 1 "1".
n=12,1,2,3,4,5,6,7,8,9,10,11,12. There were 5 "1".
Problem Solving Id
Question: implement a function that belongs to an integer and outputs the number of 1 in the binary representation. For example, if 9 is expressed as 1001 in binary notation, two digits are 1. Therefore, if 9 is input, the function outputs 2.
Possible endless loop traps
After reading the questions, I believe that you will soon be able to think of a solution: f
The specific question is as follows:Select N numbers from 1-9 to Form N-digit numbers that are not repeated. Numbers are numbered from small to large. When you enter any number M, you can find the corresponding number.. For example, N = 3, M = 213. output: [123 (1), 132 (2), 213 (3), 231 (4), 312 (5), 321 (6)] ---> X =
First, the topic requirementsGiven a positive integer in decimal, write down all integers starting with 1, to N, and then count the number of "1" that appears. Requirement: Write a function f (n) to return the number of "1" occurrences between
Bombtime limit: 2000/1000 MS (Java/others) memory limit: 131072/65536 K (Java/Others)
Total submission (s): 7187 accepted submission (s): 2512
Problem descriptionthe counter-terrorists found a time bomb in the dust. but this time the terrorists improve on the time bomb. the number sequence of the time bomb counts from 1 to n. if the current number sequence betwe
Borrow the QLS translation.Now there are n stones, A and B take the stones in turn, a first, each time up to a maximum of M stones, the last one to win the stone, but someone if the stone when the remaining stones in the binary representation of the number of odd number 1, this person lostGiven N and M, ask who winsNTL 2s before I was never exposed to the game of
Method 1: Delete the automatically numbered field and create the same automatically numbered field. Method 2: the automatic number is always added (1 is added each time). If you add another record, the number will be added to 1 (the deleted
I. Topics and Requirements
Given a positive integer in decimal, write down all integers starting with 1, to N, and then count the number of "1" that appears.
Requirement: Write a function f (n) to return the number of "1" occurrences between
Interview Question 1: the number of questions to be submitted, and questions to be submitted
Source: Public platform Chapter 9 algorithm. Since the 9-Chapter algorithm only provides the algorithm and does not provide the source code, I have provided the source code based on my own capabilities. Of course, there may be many shortcomings. I hope you will not give me any advice. ---- Xiao ran
Description:
Ther
Problem description
In the production database, the data of one table is 1 billion level, and that of the other table is 10 billion level. The data of other tables is also quite large. I didn't know that these tables had such a large amount of data before I got started, so I used to use count (*) to calculate the number of records in the table. However, this execution was terrible. After running for more t
Evaluate the number of 1 in the binary of an integer.
Question: enter an integer to calculate the number of 1 in the Binary Expression of this integer. For example, input 10. Because the binary value is 1010 and there are two 1 s, Output 2.
Analysis: this is a basic examinat
First, the experimental topicGiven a positive decimal integer, write down all integers starting at 1, to N, and then count the number of 1.Requirements:1. Write a function f (N) and return the number of "1" between
In my other article "counting of number 1 in a positive integer (I)", a simple algorithm is implemented to calculate F (n ). This algorithm is based onOnly the variation of two adjacent numbers is considered. Therefore, when calculating a single long integer (for example, n = 9111111110999009l), you canIt takes a long time to complete the calculation. Obviously, this algorithm has a narrow application scope
How can we get the number 1 after this number is converted to binary given a number (assuming 32 bits?
Solution:
X = (X 0x55555555) + (x> 1) 0x55555555)
X = (X 0x33333333) + (x> 2) 0x33333333)
X = (X 0x0f0f0f) + (x> 4) 0x0f0f0f)
X = (X 0x0000ffff) + (x>
Topic:BombTime limit:2000/1000 MS (java/others) Memory limit:131072/65536 K (java/others)Total submission (s): 9273 Accepted Submission (s): 3275Problem DescriptionThe Counter-terrorists found a time bomb in the dust. But this time, the terrorists improve on the time bomb. The number sequence of the time bomb counts from 1 to N. If The current number sequence i
Question: enter an integer to calculate the number of 1 in the Binary Expression of this integer. For example, input 10. Because the binary value is 1010 and there are two 1 s, Output 2.
Analysis: this is a basic examination bit operation interview question. Many companies, including Microsoft, have used this question.
The basic idea is to first judge whether the
Http://codeforces.com/contest/348/problem/BB. Apple TreeTime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputYou is given a rooted tree with n vertices. In each leaf vertex there's a single integer-the number of apples in this vertex.The weight of a subtree is the sum of any numbers in this subtree leaves. For instance, the weight of a subtree that corresponds to some leaf are the
Question: enter an integer to calculate the number of 1 in the Binary Expression of this integer. For example, input 10. Because the binary value is 1010 and there are two 1 s, Output 2.
Analysis: this is a basic examination bit operation interview question. Many companies, including Microsoft, have used this question.
The basic idea is to first judge whether the
Bit operations:Shift left: MShift right: m>>n m to the right of N-bit, the right shift after the high-level supplement is the sign bit, negative Supplement 1, Integer supplement 0. (Positive boundary value is (1,OX7FFFFFFF), negative value is (OX80000000,OXFFFFFFFF))Topic One: Please implement a function, enter an integer, output this number of binary representat
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.