和之前的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. sFlow-rt安装部署

      sFlow技术是一种以设备端口为基本单元的数据流随机采样的流量监控技术,不仅可以提供完整的第二层到第四层甚至全网范围内的实时流量信息,而且可以适应超大网络流量(如大于10Gbit/s)环境下的流量 ...

  2. Collection和Collections的区别是什么

    1)java.util.Collection是一个集合顶层接口,该接口的设计目的是为各种具体的集合提供最大化的统一的操作方式,它提供了对集合对象进行基本操作的通用接口方法,实现该接口的类主要有List ...

  3. 学习C语言以及C语言基础调查

    学习声乐的心得 你有什么技能比大多人(超过90%以上)更好?   就我个人而言,在所有的兴趣之中,做得比较好的应该属于声乐. 针对这个技能的获取你有什么成功的经验?   我对于声乐处始于兴趣,成功的经 ...

  4. sql2005性能优化(在32位系统上突破2G内存使用量的方法) .

    转载自http://blog.csdn.net/soldierluo/article/details/6589743 服务器磁盘为(SAS)IBM组成RAID0+1,SQL2K5只识别4G内存,实际只 ...

  5. ios蓝牙自定义快捷键

    http://www.paopaoche.net/app/12072.html Beekeyboard  

  6. Java crash问题分析

    Java的应用有时候会因为各种原因Crash,这时候会产生一个类似java_errorpid.log的错误日志.可以拿到了 这个日志,怎样分析Crash的原因呢?下面我们来详细讨论如何分析java_e ...

  7. MZOJ 1134: 二叉苹果树

    按书上大的,dfs还需加强 #include <bits/stdc++.h> #define read read() using namespace std; int read { ; c ...

  8. from __future__ import

    读代码的过程中看到的,好奇搜索了一下,其实当在我们调试别人Python代码的过程中经常会遇到一些问题,比如版本不同,代码也会有所改变,比如print函数 Python 2.7版本为 print “ ” ...

  9. 2019.02.09 codeforces gym 100548F. Color(容斥原理)

    传送门 题意简述:对n个排成一排的物品涂色,有m种颜色可选. 要求相邻的物品颜色不相同,且总共恰好有K种颜色,问所有可行的方案数.(n,m≤1e9,k≤1e6n,m\le1e9,k\le1e6n,m≤ ...

  10. CodeCraft-19 and Codeforces Round #537 (Div. 2) D 多重排列 + 反向01背包 + 离线处理

    https://codeforces.com/contest/1111/problem/D 多重排列 + 反向01背包 题意: 给你一个字符串(n<=1e5,n为偶数),有q个询问,每次询问两个 ...