文件名称:Sum
介绍说明--下载内容均来自于网络,请自行研究使用
算法实现题1-2 连续和问题
« 问题描述:
给定一个正整数n,计算有多少个不同的连续自然数段,其和恰为n。例如,当n=27
时,有4 个不同的连续自然数段的和恰为27:2+3+4+5+6+7;8+9+10;13+14;27。
« 编程任务:
给定一个正整数n,试设计一个O(n)时间算法,计算有多少个不同的连续自然数段的
和恰为n。
« 数据输入:
由文件input.txt提供输入数据。文件的第1 行是正整数n。
« 结果输出:
程序运行结束时,将计算出的和恰为n的连续自然数段的个数输出到output.txt中。
输入文件示例 输出文件示例
input.txt 27
output.txt 4
-Algorithm 1-2 consecutive title and the issue of ?Descr iption of the problem: given a positive integer n, calculate the number of consecutive natural number of different paragraph, and its and exactly n. For example, when n = 27, there were four different sections for natural and exactly 27:22 B! 3+ 4+ 5+ 6+ 7 8+ 9+ 10 13+ 14 27. ?Programming tasks: Given a positive integer n, try to design a O (n) time algorithm to calculate the number of different section of consecutive natural numbers and exactly n. ?Data input: from file input.txt to provide input data. Paragraph 1 line is a positive integer n. ?The results output: program to run at the end will be calculated and exactly the consecutive natural number n the number of paragraphs in the output to output.txt. Sample input file output file example input.txt 27 output.txt 4
« 问题描述:
给定一个正整数n,计算有多少个不同的连续自然数段,其和恰为n。例如,当n=27
时,有4 个不同的连续自然数段的和恰为27:2+3+4+5+6+7;8+9+10;13+14;27。
« 编程任务:
给定一个正整数n,试设计一个O(n)时间算法,计算有多少个不同的连续自然数段的
和恰为n。
« 数据输入:
由文件input.txt提供输入数据。文件的第1 行是正整数n。
« 结果输出:
程序运行结束时,将计算出的和恰为n的连续自然数段的个数输出到output.txt中。
输入文件示例 输出文件示例
input.txt 27
output.txt 4
-Algorithm 1-2 consecutive title and the issue of ?Descr iption of the problem: given a positive integer n, calculate the number of consecutive natural number of different paragraph, and its and exactly n. For example, when n = 27, there were four different sections for natural and exactly 27:22 B! 3+ 4+ 5+ 6+ 7 8+ 9+ 10 13+ 14 27. ?Programming tasks: Given a positive integer n, try to design a O (n) time algorithm to calculate the number of different section of consecutive natural numbers and exactly n. ?Data input: from file input.txt to provide input data. Paragraph 1 line is a positive integer n. ?The results output: program to run at the end will be calculated and exactly the consecutive natural number n the number of paragraphs in the output to output.txt. Sample input file output file example input.txt 27 output.txt 4
(系统自动生成,下载前可以参看下载内容)
下载文件列表
Sum.cpp