和之前的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. less 官网讲解 ( http://www.bootcss.com/p/lesscss/ )

    变量 变量允许我们单独定义一系列通用的样式,然后在需要的时候去调用.所以在做全局样式调整的时候我们可能只需要修改几行代码就可以了. // LESS @color: #4D926F; #header { ...

  2. 定时任务起的java进程没有释放导致oracle的问题not availavle & out of memory

    最近发现一个问题,我们设置了一个定时任务,用于每天的对账,每天的对账都是启动一个java程序(jar包),时间久了,出现下面的问题: 有很多CardPaymentBatch.jar进程驻留在系统当中, ...

  3. nodejs 数字字节转换操作

    function number2Bytes(i) { var arr = new Int32Array(1); arr[0] = 0; var buf = Buffer.from(arr.buffer ...

  4. 需求文件requirements.txt的创建及使用

    pip freeze >requirements.txt pip install -r requirements.txt

  5. Java界面编程—事件监听机制

    组件首先要先注册事件处理器,当用户单击组件.移动鼠标或者敲击键盘时都会产生事件(Event),一旦有时间发生,应用程序就会做出对该事件的响应,这些组件就是事件源(Event source). 接受.解 ...

  6. rabbitmq安装.教程

    https://www.cnblogs.com/ericli-ericli/p/5902270.html (rabbitmq安装)https://www.cnblogs.com/iiwen/p/538 ...

  7. java 多态的深入理解

    简单来说 : 多态 能够很好的解决代码耦合性的问题 考虑这样一个场景 有个人 买了辆捷达汽车 .这个系统应该如何设计呢? public class JettaCar { public void run ...

  8. Android中关于使用空格对齐文字

    前言:今日编写新项目UI时,突然遇到文本有长有短无法对齐的问题(汗,以前竟从未遇到也从未考虑过这小小的问题),在资源文件中尝试Tab键.space空格键,发现效果都不能很好的实现,无奈只得请求度娘的协 ...

  9. Python内置的subprocess.Popen对象

    具体内容参见:https://docs.python.org/3/library/subprocess.html 大概来说,就是可以对应输入的命令产生一个进程,该进程实例内置如下方法. |  comm ...

  10. 2017/2/5:oracle数据库的三大文件

    oracle的三大文件: 一:控制文件:控制文件是一个小型的二进制文件,可以记录数据库的物理结构.包括:     * 数据库名称     * 数据文件和日志文件的名称和位置     * 数据库创建的时 ...