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
代码:
static List<String> list = new ArrayList<String>();
/**
*

给定一个序列S,例如{1, 2, 3},求解其中非递减子序列的数量。输入包含序列长度n(1 <= n <= 100000)和序列本身,输出所有非递减子序列数量对1000000007取模的结果。样例输入为序列长度3及序列{1, 2, 3},输出应为7。"
108857932,9211270,HALCON差异模板在打印质量检测中的应用,"['计算机视觉', '图像处理', '机器学习', '模板匹配', '自动化检测']
最低0.47元/天 解锁文章
2751

被折叠的 条评论
为什么被折叠?



