编程介的小学生
2019-02-25 20:20查找最大的非递减的序列的一个算法的问题采用C语言进行解答
Problem Description
How many nondecreasing subsequences can you find in the sequence S = {s1, s2, s3, ...., sn} ? For example, we assume that S = {1, 2, 3}, and you can find seven nondecreasing subsequences, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}.
Input
The input consists of multiple test cases. Each case begins with a line containing a positive integer n that is the length of the sequence S, the next line contains n integers {s1, s2, s3, ...., sn}, 1 <= n <= 100000, 0 <= si <= 2^31.
Output
For each test case, output one line containing the number of nondecreasing subsequences you can find from the sequence S, the answer should % 1000000007.
Sample Input
3
1 2 3
Sample Output
7
- 点赞
- 回答
- 收藏
- 复制链接分享
0条回答
为你推荐
- 输入n(1≤n≤10)个整数,用冒泡排序法对其从小到大排序,共进行n-1趟,要求输出每一趟的排序情况
- c语言
- c++
- 冒泡排序法
- 2个回答
- c语言 设计一个找出同数值部分排列的程序
- 设计
- 2个回答
- 求二叉树问题的C程序代码
- c语言
- 二叉树
- 2个回答