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 ...
随机推荐
- SDOI2019Round1游记
SDOI2019Round1游记 Day 0 报道日,早晨五点睡的觉,一觉醒来已经一点半了,收拾收拾东西报道去了.因为没吃饭,坐着出租车晕车了,我让师傅把我放到历下大润发,我去金拱门吃了点饭才去的23 ...
- 原生JS操作AJAX
1,get方式的AJAX function sendAjaxReq() { //1,创建ajax引擎 XMLHttpRequest对象 var req = new XMLHttpRequest() | ...
- Jsoup解析网页html
Jsoup解析网页html 解析网页demo: 利用Jsoup获取截图中的数据信息: html代码片段: <!-- 当前基金档案\计算\定投\开户 start --> <div cl ...
- Mysql截取和拆分字符串函数用法
Mysql截取和拆分字符串函数用法 截取字符串函数: SUBSTRING(commentid,9) 意思是:从第9个字符开始截取到最后.SUBSTRING的参数有三个,最后一个是截取的长度,默认是到结 ...
- JavaScript 创建动态表格
JavaScript 创建动态表格 版权声明:未经授权,严禁转载! 案例代码 <div id="data"></div> <script> va ...
- 泛型编程之特性(traits)
特性(traits):对于某种可能会出错的返回值型别(Return Type),利用类模版进行部分特例化.其思想类似设计模式. 我们只能部分特例化类模板,而不能部分特例化函数模版.——<C++ ...
- Cron表达式详解和表达式的验证
本篇不算原创,因为主要内容来自网上的博客,所以给出我参考文章的链接. 本文cron表达式详解的大部分内容参考了[cron表达式详解]和Quartz使用总结.Cron表达式 这两篇文章. cron校验的 ...
- Python3基础 global 使函数中的局部变量升格为全局变量
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- C#中配置文件保存的路径
http://www.codeproject.com/Tips/350010/Saving-User-Settings-in-Winform-Application 外网上找的资料 winform提供 ...
- java面试项目经验:框架及应用
Java项目经验 Java就是用来做项目的!Java的主要应用领域就是企业级的项目开发!要想从事企业级的项目开发,你必须掌握如下要点:1.掌握项目开发的基本步骤2.具备极强的面向对象的分析与设计技巧3 ...