题目链接:http://codeforces.com/problemset/problem/314/C 题意:给定一个数列a.(1)写出a的不同的所有非下降子列:(2)定义某个子列的f值为数列中各个数的乘积.(3)求所有非下降子列的f值之和. 思路:我们用s[i]表示以数字a[i]结尾的所有非下降子列的f之和.那么a必然是接在之前小于等于a的某个数之后,设这个位置为j,那么s[i]=(s[j]+1)*a[i].也就是,a[i]可以接在其后或者自成一个子列.那么最后的答案就是所有的s值之和.这里有…
题目链接:http://codeforces.com/contest/597/problem/C 给你n和数(1~n各不同),问你长为k+1的上升自序列有多少. dp[i][j] 表示末尾数字为i 长度为j的上升子序列个数,但是dp数组是在树状数组的update函数中进行更新. update(i, val, j)函数表示在i的位置加上val,更新dp[i][j]. sum(i, j)就是求出末尾数字小于等于i 且长度为j的子序列有多少个. //#pragma comment(linker, "/…
这个题目的数据感觉不能更水了.从复杂度上计算,肯定有极限数据可以卡掉暴力方法的么. 总之,暴力的做法就是树状数组了,对于区间更新,就挨个更新就是了.当然,判断是否是Lucky Number的话,可以用一个数组标记一下,因为题目中有说数据不会超过10000的.总之就是一个非常不靠谱的方法过了……话说用线段树的区间操作以及延迟标记的话,真心不知道怎么判断加上d之后的Lucky Number的个数,o(╯□╰)o #include <cstdio> #include <cstring>…
设$f(i, j)$表示以$i$结尾的,长为$j$的上升子序列的数量 转移时用树状数组维护即可 复杂度为$O(kn \log n)$ 注:特判0 #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> namespace remoon { #define ri register int #define ll long long #define tpr temp…
http://www.lightoj.com/volume_showproblem.php?problem=1085 题意:求一个序列的递增子序列个数. 思路:找规律可以发现,某个数作为末尾数的种类数为所有比它小的数的情况+1.使用树状数组查找即可. C++11 的auto在Lightoj上不能用/.\ /** @Date : 2016-12-01-21.58 * @Author : Lweleth (SoungEarlf@gmail.com) * @Link : https://github.…
C. Subsequences     For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed that the answer is not greater than 8·1018. Input   First line contain two integer values n and k (1…
C. Subsequences Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/597/problem/C Description For the given sequence with n different elements find the number of increasing subsequences with k + 1 elements. It is guaranteed tha…
#include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <cmath> #include <map> #include <vector> using namespace std; long long num[1000005]; long long fz[1000005]; long long xds[100…
Sereja has a sequence that consists of n positive integers, a1, a2, ..., an. First Sereja took a piece of squared paper and wrote all distinct non-empty non-decreasing subsequences of sequence a. Then for each sequence written on the squared paper, S…
题意:给定一个N个数的数列,求所有不同不下降子序列的乘积之和,其中不同指的是组成它的数字和长度不完全相同 n (1 ≤ n ≤ 10^5) a[i]<=10^6 思路:考虑DP.设DP[a[i]]为最后一位为a[i]时所有序列的积之和,则dp[a[i]]=a[i]+sigma(dp[a[j]]) *a[i] (a[j]<=a[i],j<i) 后一部分可以用树状数组计算 为了去除最后一位相同的序列比如1 2 2 这个序列中1 2这个子序列只能算一遍 要强行去掉原来最后一位为a[i]的序列…