dow

Hive笔记

穿精又带淫゛_ 提交于 2020-03-20 14:02:35
1、-- 导入数据 load data local inpath '/home/badou/Documents/data/order_data/orders.csv' overwrite into table orders; 2、每个用户有多少个订单 hive> select user_id,count(1) as order_cnt from orders group by user_id order by order_cnt desc limit 10; Total jobs = 2 Launching Job 1 out of 2 Number of reduce tasks not specified. Estimated from input data size: 1 In order to change the average load for a reducer (in bytes): set hive.exec.reducers.bytes.per.reducer=<number> In order to limit the maximum number of reducers: set hive.exec.reducers.max=<number> In order to set a constant number of reducers: set mapred

[CSP校内集训]tree(期望DP)

徘徊边缘 提交于 2019-12-02 04:37:02
题意 给一颗树,从1节点出发,走每条边的概率相同且耗时为1,求每个点第一次被遍历到的期望时间( \(t_1=1\) ) 思路 在树上只有两种移动方式:从儿子到父亲,从父亲到儿子 假设从 \(rt\) 转移到 \(v\) 的期望代价为 \(dow_i\) ,从 \(i\) 转移到 \(rt\) 的期望代价为 \(val_i\) 假设从 \(rt\) 转移到 \(v\) , \(rt\) 的度数为 \(k\) , \(rt\) 的父亲为 \(fa\) ,则: \[dow_v = \frac{1}{k} + \sum_{son}^{son\neq v} { \frac{1}{k}\times (1+val_{son}+dow_v)} + \frac{1}{k}\times (1+dow_{fa}+dow_v)\] 意思是:要么从 \(rt\) 到 \(v\) 一步到位,要么有 \(\frac{1}{k}\) 的概率走其他点再走回来重新计算期望 这里还有个 \(val\) 不知道,所以要先计算它: \[val_{rt} = \sum_{son} {\frac{1}{k} + \frac{1}{k} \times (1+val_{son}+val_{rt})}\] 意思是:要么从 \(v\) 到 \(rt\) 一步到位,要么走一步到儿子走回来在重新计算期望 一遍 \(dfs\) 自底向上求