poj3378 树状数组 + 离散化 + 高精度
来源:互联网 发布:苹果编程游戏 编辑:程序博客网 时间:2024/05/08 08:29
其实.,我没有AC,因为...高进度不会,所以没有搞.ok,这个是我直接一次后的代码.是为了以后再做这一题用的
#include <stdio.h>#include <string>#include <string.h>#include <queue>#include <stack>#include <map>#include <iostream>#include <stdlib.h>#include <math.h>#include <set>#include <algorithm>#define inf 0x3f3f3f3f#define mem0(x , y) memset(x , y , sizeof(x))#define ll long long#define LL long long#define rep(x , y) for(int x=0;x<y;x++)#define per(x , y) for(int x=y-1;x>=0;x--)#define lowbit(x) (x & (-x))#define read(x) scanf("%d",&x)#define print(x) printf("%d\n" , x) ;#define middle int mid = (l + r)/2#define lson rt<<1 , l , mid#define rson rt<<1|1 , mid+1, r#define CASE int T ; int ca = 0 ; read(T) ; while(T--)#define RT tree[rt]#define FP freopen("1" , "r" , stdin)#define mem0(x , y) memset(x , y , sizeof(x))#define BIN(x) ll bin ; bin = (ll)1 << x ; ///2的x次方#define E Edge[i]#define lowbit(x) (x & (-x))const int MAXN = 500000 ;const int MAXV = 200000 ;const int MAXE = 200000 ;const int mod = 1e8+7 ;using namespace std ;/****************前向星****************struct edge{ int s , e , w , next ; bool operator < (const edge & e) const{ return w < e.w ; }}Edge[MAXE] ;int head[MAXV] , hct = 0 ;void add_edge(int s,int e,int w){ Edge[hct].s = s ; Edge[hct].e =e ;Edge[hct].w = w ; Edge[hct].next = head[s] ; head[s] = hct ++ ;}/*************************************/int BIT[1000000] ;const int MAXB = 1000000 ;void add(int x,int val){ x ++ ; while(x < MAXB) BIT[x] += val , x += lowbit(x) ;}int query(int x){ int ans = 0 ; while(x) ans += BIT[x] , x -= lowbit(x) ; return ans ;}int hs[1000000] , ch = 0 ;int da[1000000] ;int dp[1000000][6] ;int find(int x){ return lower_bound(hs , hs+ch , x) - hs ;}int main(){ int n ;while(read(n)!=EOF){ ch = 0 ; rep(i , n) read(da[i]) , hs[ch++] = da[i] ; sort(hs , hs+ch) ; ch = unique(hs , hs+ch) - hs ; for(int i=0;i<n;i++) dp[i][1] = 1 ; for(int l=2;l<=5;l++){ mem0(BIT , 0) ; for(int i=0;i<n;i++){ dp[i][l] = query(find(da[i])) ; add(find(da[i]) , dp[i][l-1]) ; } } int ans = 0 ; for(int i=0;i<n;i++){ ans += dp[i][5] ; } printf("%d\n",ans) ; }}
0 0
- poj3378 树状数组 + 离散化 + 高精度
- POJ3378:Crazy Thairs(动态规划+线段树或树状数组+离散化+高精度)
- poj3378 Crazy Thairs 高精度,树状数组
- POJ 3378 - Crazy Thairs 树状数组+dp+离散化+高精度..
- Crazy Thairs_poj3378_DP+离散+高精度+树状数组
- 树状数组--离散化
- Flowers&&树状数组+离散化
- hdu4417(离散化+树状数组)
- POJ2299 树状数组+离散化
- poj2299 离散化+树状数组
- hdu4325 树状数组+离散化
- hdu5372 离散化+树状数组
- poj2299 树状数组+离散化
- poj2299离散化,树状数组
- hdu5862树状数组 离散化
- hdu5877dfs,树状数组离散化
- POJ2299 树状数组+离散化
- 工资管理 树状数组+离散化
- EL表达式详解
- guava常用简化操作
- IDEA下openfire源码编译过程记录
- android 游戏 实战打飞机游戏 实现无限循环的背景图(2)
- 大数据从何而来?你必须知道的7个数据源供应平台
- poj3378 树状数组 + 离散化 + 高精度
- Easyui前端知识点收集
- Qt界面多语言国际化的实现
- 如何添加一个带标记的编辑器
- 虚拟机性能监控与故障处理工具
- 把/var下的文件置为777权限的后果
- Android布局常用代码片段
- Android 状态栏通知Notification、NotificationManager详解
- Minigui3在海思Hi3520D/Hi3531平台上运行