和之前的hdu3030都快一样了

可以参考之前的题解

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn = 1e5+;
long long n;
long long a[maxn];
long long b[maxn];
long long c[maxn];
long long mod = 1e9+;
void add(long long c[],long long i,long long j);
long long getsum(long long c[],long long i);
int main()
{
int i,j,k;
while(scanf("%lld",&n) != EOF)
{
memset(c, , sizeof(c));
for(i=;i<=n;++i)
{
scanf("%lld",a+i);
b[i] = a[i];
}
sort(b+,b+n+);
long long sum = ;
for(i=;i<=n;++i)
{
long long ans=;
long long pos=lower_bound(b+,b+n+,a[i]) - b;
ans = getsum(c,pos);
sum += ans+;
sum %= mod;
add(c, pos, ans+);
}
printf("%lld\n",sum);
}
}
long long lowbit(long long k)
{
return k&(-k);
}
void add(long long c[],long long i,long long j)
{
while(i<=n)
{
c[i] += j;
c[i] %= mod;
i += lowbit(i);
}
}
long long getsum(long long c[],long long i)
{
long long sum = ;
while(i > )
{
sum += c[i];
sum %= mod;
i -= lowbit(i);
}
return sum;
}

hdu 2227的更多相关文章

  1. HDU 2227 Find the nondecreasing subsequences (DP+树状数组+离散化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2227 Find the nondecreasing subsequences             ...

  2. HDU 2227 Find the nondecreasing subsequences dp思想 + 树状数组

    http://acm.hdu.edu.cn/showproblem.php?pid=2227 用dp[i]表示以第i个数为结尾的nondecreasing串有多少个. 那么对于每个a[i] 要去找 & ...

  3. HDU 2227 Find the nondecreasing subsequences

    题目大意:给定一个序列,求出其所有的上升子序列. 题解:一开始我以为是动态规划,后来发现离散后树状数组很好做,首先,c保存的是第i位上升子系列有几个,那么树状数组的sum就直接是现在的答案了,不过更新 ...

  4. HDU 2227 Find the nondecreasing subsequences (线段树)

    Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/3 ...

  5. HDU 2227 Find the nondecreasing subsequences(DP)

    Problem Description How many nondecreasing subsequences can you find in the sequence S = {s1, s2, s3 ...

  6. HDU 2227 Find the nondecreasing subsequences (数状数组)

    Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/3 ...

  7. hdu 2227(树状数组+dp)

    Find the nondecreasing subsequences Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/3 ...

  8. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

  9. BIT 树状数组 详解 及 例题

    (一)树状数组的概念 如果给定一个数组,要你求里面所有数的和,一般都会想到累加.但是当那个数组很大的时候,累加就显得太耗时了,时间复杂度为O(n),并且采用累加的方法还有一个局限,那就是,当修改掉数组 ...

随机推荐

  1. Django权限系统auth

    auth模块是Django提供的标准权限管理系统,可以提供用户身份认证, 用户组和权限管理. auth可以和admin模块配合使用, 快速建立网站的管理系统. 在INSTALLED_APPS中添加'd ...

  2. chrome、firefox表单自动提交诱因 -- 非type=hidden的单输入域(input)

    开发任务中遇到很费解的一个form自动提交问题,form中只有一个input时回车会触发自动提交表单,当在多一个非type=hidden的input时,又不会出现表单自动提交. 代码示例: 会出现自动 ...

  3. Python中sys和os模块的区别

    sys: This module provides access to some variables used or maintained by the interpreter and to func ...

  4. 如何将service绑入到spring 并且在action中使用

    第一步:定制 service接口,为什么用接口我也不清楚 package com.inspur.services; import com.hsp.domain.User; public interfa ...

  5. 2017/2/6:在oracle中varchar与varchar2的区别与增删改查

    1.varchar2把所有字符都占两字节处理(一般情况下),varchar只对汉字和全角等字符占两字节,数字,英文字符等都是一个字节:2.VARCHAR2把空串等同于null处理,而varchar仍按 ...

  6. SQL Server 2008中的MERGE(不仅仅是合并)

    SQL Server 2008中的MERGE语句能做很多事情,它的功能是根据源表对目标表执行插入.更新或删除操作.最典型的应用就是进行两个表的同步. 下面通过一个简单示例来演示MERGE语句的使用方法 ...

  7. 绩效沟通-BEST原则

    BEST原则指在进行绩效/IDP面谈的时候按照以下步骤进行: 案例:小赵经常在制作标书时候犯错误 Behavior description 描述行为 小赵,8月6日,你制作的标书,报价又出现了错误,单 ...

  8. oracle 重建分区索引

    分区表的所有分区相当于一个单独的表. 创建在分区表上的索引,就相当于在所有分区上单独创建的索引(主键索引除外). 重建分区表的索引回报: ORA-14086:不能将分区索引作为整体重建. so,重建语 ...

  9. MySQL mysqldump 数据备份

    1.mysqldump 命令工具说明 参数注解: mysqldump 是采用SQL 级别的备份机制,它将数据表导成 SQL 脚本文件,在不同的 MySQL 版本之间升级时相对比较合适,这也是最常用的备 ...

  10. 2018.11.06 NOIP训练 简单的计数问题(计数dp)

    传送门 直接f[i][j]f[i][j]f[i][j]表示已经到第iii个位置已经找到jjj个的方案数. 简单转移一下就行了. 代码