Questions about today's Baidu program competition

Source: Internet
Author: User

ZZ from another place, Copyleft ......

Submit the C/C ++ source after development and debugging.ProgramThe system will automatically display the compilation result: (If your browser does not allow a new window to pop up, modify the browser settings to allow a new window to pop up. Do not submit functions that contain file write operations, network programming, and system calls. errors may occur during compilation .)

Question 1 (100 points in total): continuous positive integer (10 points)

Description: a positive integer may be expressed as the sum of n (n> = 2) continuous positive integers, for example:
15 = 1 + 2 + 3 + 4 + 5
15 = 4 + 5 + 6
15 = 7 + 8
Write a program to find all consecutive positive integer sequences that meet the input positive integer. Input data: A Positive Integer provided to the program as a command line parameter. Output Data: print all positive integer sequences that conform to the topic description on the standard output. Each sequence has one sequence per row. Each sequence starts from the smallest positive integer of the sequence and is printed in ascending order. If the result has multiple sequences, print the smallest positive integers of each sequence from small to large. In addition, the sequence cannot be repeated. integers in the sequence are separated by a space. If there is no matching sequence, "NONE" is output ".
For example, for 15, the output result is:
1 2 3 4 5
4 5 6
7 8
For 16, the output result is:
None
Rating criteria: whether the program output result is correct.

Question 2 (100 points for all four questions): size of the overlap interval (20 points)

Description: write a program to find out the maximum overlap interval in the input data file described in "input data and format" below.
For a positive integer N, if n is between two positive integers (assume a and B) in a row in the data file, that is, if a <= n <= B or a> = n> = B, n belongs to the row. If n belongs to both I and J, there is an overlap between I and j; the size of the overlap interval is the number of integers belonging to both row I and J.
For example, the overlapping ranges of rows (10 20) and (12 25) are [12 20], and the size is 9; rows (20 10) and (12 18) the overlap interval of is [10 12], and the size is 3; the overlap interval of rows (20 10) and (20 30) is 1. Input data: The program reads the input data text file named input.txt. The number of lines in the file is between 1 and 1,000,000. Each line uses two integers separated by a space. The size order of these two integers is random, each number is between 1 and 2 ^ 32-1. (For convenience, you can download the input.txt file. In actual running, we will use an input file with different content .) Output Data: The maximum overlap interval in the input data file is printed on the standard output. If no overlap interval exists for all rows, 0 is output. Scoring standard: The program output result must be correct, and the memory usage must not exceed 256 MB. The faster the program runs, the better.

Question 3 (100 points for all four questions): String replacement (30 points)
 
Description: write a program to replace the string in a text with another string based on the specified correspondence. Input data: bytes is another text (including Chinese) indicating the correspondence between string (S1) and string (S2), which is about 10 thousand rows, each line contains two strings (S1 and S2) separated by a \ t or space. The S1 of each row in dict.txt is not sorted and may be duplicated. In this case, the S2. Each string in text.txtand dict.txt may contain any character except whitespace. Only S1 in text.txt and dict.txt can be replaced. (For convenience, you can download the text.txtand dict.txt files. The input files with different content will be used during actual running .) Output Data: print the entire text after text.txtis replaced by dict.txt on the standard output. Rating criteria: the program output result must be correct. The smaller the memory usage, the better the program execution time.

Question 4 (100 points in total): Low Frequency Word filtering (40 points)
 
Topic Description: write a program to delete words with the least number of occurrences from texts containing a large number of words. If multiple words appear for a minimum number of times, delete them. Input data: The program reads a large data size text file named corpus.txt, which contains English words and Chinese words, separated by one or more whitespaces. (For convenience, you can download the test corpus.txt file. We will use an input file with different content during actual running .) Output Data: print the text after the words that appear in corpus.txt with the least number of times in the standard output (words and words remain in the original order and are still separated by spaces ). Rating criteria: the program output result must be correct. The smaller the memory usage, the better the program execution time.

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.