hdu-2227-dp+bit
Find the nondecreasing subsequences
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2213 Accepted Submission(s): 858
1 2 3
#include<bits/stdc++.h>
using namespace std;
#define ULL unsigned long long
#define LL long long
LL mod=1e9+;
LL C[];
int N;
struct node{
int v,d;
bool operator<(const node& C)const{
if(v!=C.v) return v<C.v;
return d<C.d;
}
}a[];
bool cmp(node A,node B){return A.d<B.d;}
int main(){
int i,j;
while(scanf("%d",&N)==){
LL ans=;
for(i=;i<=N;++i) scanf("%d",&a[i].v),a[i].d=i;
sort(a+,a++N);
for(i=;i<=N;++i) a[i].v=i;
sort(a+,a++N,cmp);
for(i=;i<=N;++i){
LL tmp=;
for(int x=a[i].v;x>;x-=(x&-x)) (tmp+=C[x])%=mod;
for(int x=a[i].v;x<=N;x+=(x&-x)) (C[x]+=tmp)%=mod;
(ans+=tmp)%=mod;
}
printf("%lld\n",ans);
memset(C,,sizeof(C));
}
return ;
}
hdu-2227-dp+bit的更多相关文章
- hdu 3016 dp+线段树
Man Down Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total S ...
- HDU 5928 DP 凸包graham
给出点集,和不大于L长的绳子,问能包裹住的最多点数. 考虑每个点都作为左下角的起点跑一遍极角序求凸包,求的过程中用DP记录当前以j为当前末端为结束的的最小长度,其中一维作为背包的是凸包内侧点的数量.也 ...
- HDU 2227 Find the nondecreasing subsequences (DP+树状数组+离散化)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2227 Find the nondecreasing subsequences ...
- HDU 2227 Find the nondecreasing subsequences dp思想 + 树状数组
http://acm.hdu.edu.cn/showproblem.php?pid=2227 用dp[i]表示以第i个数为结尾的nondecreasing串有多少个. 那么对于每个a[i] 要去找 & ...
- HDU 2227 Find the nondecreasing subsequences(DP)
Problem Description How many nondecreasing subsequences can you find in the sequence S = {s1, s2, s3 ...
- hdu 2227(树状数组+dp)
Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/3 ...
- HDU 1069 dp最长递增子序列
B - Monkey and Banana Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I6 ...
- HDU 1160 DP最长子序列
G - FatMouse's Speed Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64 ...
- hdu 4826(dp + 记忆化搜索)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4826 思路:dp[x][y][d]表示从方向到达点(x,y)所能得到的最大值,然后就是记忆化了. #i ...
- HDU 2861 (DP+打表)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2861 题目大意:n个位置,m个人,分成k段,统计分法.S(n)=∑nk=0CknFibonacci(k ...
随机推荐
- 获取Linux时间函数
Linux下clock_gettime函数详解 要包含这头文件<time.h> 且在编译链接时需加上 -lrt ;因为在librt中实现了clock_gettime函数. --- stru ...
- Django框架----基础
一个小问题: 什么是根目录:就是没有路径,只有域名..url(r'^$') 补充一张关于wsgiref模块的图片 一.MTV模型 Django的MTV分别代表: Model(模型):和数据库相关的,负 ...
- P4052 [JSOI2007]文本生成器
P4052 [JSOI2007]文本生成器 AC自动机+dp 优秀题解传送门 设f[ i ][ j ]表示串的长度为 i ,当前在 j 点时不可识别的串的方案数 最后用总方案数减去不可识别方案数就是答 ...
- ”MySQL索引“学习总结
序 learn by doing 是最快的学习方式.在百度外卖研发中心,我每天工作接触数据库方面最多的就是"索引",另外面试官在面试时也一定会考察到索引. Part 1, Expl ...
- 02: tornado进阶篇
目录:Tornado其他篇 01: tornado基础篇 02: tornado进阶篇 03: 自定义异步非阻塞tornado框架 04: 打开tornado源码剖析处理过程 目录: 1.1 自定制t ...
- 03: JavaScript基础
目录: 参考W3school 1.1 变量 1.2 JavaScript中数据类型 1.3 JavaScript中的两种for循环 1.4 条件语句:if.switch.while 1.5 break ...
- 20145339顿珠 Exp5 MSF基础应用
20145339顿珠 Exp5 MS08_067漏洞测试 实验过程 IP地址:192.168.1.104 虚拟机ip:192.168.1.102 在控制台内使用search ms08_067查看相关信 ...
- HTML切换页面IE版本
<!--[if !IE]><!--> 除IE外都可识别 <!--<![endif]--><!--[if IE]> 所有的IE可识别 <![e ...
- Asp.net简单概念知识
1. 简述 private. protected. public. internal 修饰符的访问权限.答 . private : 私有成员, 在类的内部才可以访问. protected ...
- 谈谈java中的final关键字
知识点:final(最终的)关键字修饰类.方法.属性 1.final修饰类:那么这个就无法被继承,如String类.StringBuffer类.System类 2.final修饰方法:被修饰的方法不能 ...