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 ...
随机推荐
- AngularJs表单自动验证
angular-auto-validate 地址:https://github.com/jonsamwell/angular-auto-validate 引用: <script src=&quo ...
- P2512 [HAOI2008]糖果传递&&P3156 [CQOI2011]分金币&&P4016 负载平衡问题
P2512 [HAOI2008]糖果传递 第一步,当然是把数据减去平均数,然后我们可以得出一串正负不等的数列 我们用sum数组存该数列的前缀和.注意sum[ n ]=0 假设为链,那么可以得出答案为a ...
- tensorflow reduction_indices理解
在tensorflow的使用中,经常会使用tf.reduce_mean,tf.reduce_sum等函数,在函数中,有一个reduction_indices参数,表示函数的处理维度,直接上图,一目了然 ...
- Python3基础 getattr 获取对象的指定属性值
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- 获取mips32机器的各数据类型的取值范围
一.背景: 使用的mips 32bit机器,32bit的vxworks操作系统(各机器带来的范围都不一样,与操作系统也有关联) 二.验证类型的范围: 2.1 unsigned long: void m ...
- VS2017无法启动程序 操作在当前状态中是非法的
工具--选项--调试--常规--启用asp.net的JavaScript调试(chrome和ie)去掉勾选
- stm32 pwm 电调 电机
先上代码 python 树莓派版本,通俗表现原理.stm32 C语言版本在后面 import RPi.GPIO as GPIO import time mode=2 IN1=11 def setup( ...
- Elasticsearch 原理
Elasticsearch简介 Elasticsearch是一个基于Apache lucene的实时分布式搜索.具有以下优点: 1.实时处理大规模数据.2.全文检索,能够做到结构化检索和聚合分析.3. ...
- 获取客户端真实ip地址(无视代理)
/// <summary> /// 获取客户端IP地址(无视代理) /// </summary> /// <returns>若失败则返回回送地址</retur ...
- 遇到Io阻塞时会切换任务之【爬虫版】
#! /usr/bin/env python3 # -*- coding:utf- -*- from urllib import request import gevent,time from gev ...