col

sparksql系列(二) sql常规操作

余生长醉 提交于 2019-12-01 07:23:44
import java.util.Arrays import org.apache.spark.SparkConf import org.apache.spark.api.java.JavaSparkContext import org.apache.spark.sql.{DataFrame, Row, SparkSession, functions} import org.apache.spark.sql.functions.{col, desc, length, row_number, trim, when} import org.apache.spark.sql.functions.{countDistinct,sum,count,avg} import org.apache.spark.sql.types.{LongType, StringType, StructField, StructType} import org.apache.spark.sql.expressions.Window import org.apache.spark.storage.StorageLevel import org.apache.spark.sql.SaveMode object WordCount {   def initSparkAndData() : DataFrame = {  

Tree

一笑奈何 提交于 2019-12-01 04:35:43
https://loj.ac/problem/10069 题目描述   给出一张图,每条边除边权外还有颜色(黑白两色),求最小权的恰有need条白边的生成树。 思路   直接求最小生成树再不断删边和加边使得生成树恰有need条边且仍是最小权很难维护,我们可以考虑把所有白边都加上一个值,再求一遍最小生成树,可以证明这样必定可以有一种方案可以使一种求出的最小生成树恰有need条白边,这样就实现对白边数量的调节,而对于这个值我们可以进行二分。 代码 #include <bits/stdc++.h> using namespace std; const int MAXN=5e4+10,MAXM=1e5+10; struct Edge { int s,t,c,col; }e[MAXM]; int fa[MAXN],m,sum,n,need; bool cmp(Edge x,Edge y) { if(x.c==y.c)return x.col<y.col; else return x.c<y.c; } int find(int x) { return fa[x]==x?x:fa[x]=find(fa[x]); } bool check(int k) { for(int i=1;i<=m;i++) if(!e[i].col)e[i].c+=k; for(int i=0;i<n;i++) fa[i

Span attribute on colgroup and col

爷,独闯天下 提交于 2019-12-01 00:02:51
Are these codes logically equivalent? <colgroup span="7"> </colgroup> And <col span="7" /> And <colgroup> <col /> <col /> <col /> <col /> <col /> <col /> <col /> </colgroup> Will any attributes via HTML or properties via CSS have equal effect? Can sombody also add "colgroup" Tag. No enough rep for me to do that. From the specification for <col> : Contexts in which this element can be used: As a child of a colgroup element that doesn't have a span attribute. [...] Content attributes: Global attributes span I read that as saying that just <col span="7" /> on its own is invalid but this:

雪场缆车——染色

假如想象 提交于 2019-11-30 19:55:40
题目描述 约翰的表哥罗恩生活在科罗拉多州.他近来打算教他的奶牛们滑雪,但是奶牛们非常害羞, 不敢在游人如织的度假胜地滑雪.没办法,他只好自己建滑雪场了. 罗恩的雪场可以划分为$W列L行(1≤W≤500;1≤L≤500),每个方格有一个特定的高度H(O≤日≤9999).$奶牛可以在相临方格间滑雪,而且不能由低到高滑. 为了保证任意方格可以互通,罗恩打算造一些直达缆车.缆车很强大,可以连接任意两个方格,而且是双向的.而且同一个方格也可以造多台缆车. 但是缆车的建造费用贵得吓人,所以他希望造尽量少的缆车.那最少需要造多少台呢? 思路   首先看到这题感觉挺简单的,暴力$flood fill$,然后直接根据颜色数贪心即可。后来我发现我还是太naive了。   正解:要使整张图形成一个强联通分量,那么必须满足加边之后没有出度为0的点和入度为0的点,于是我们只需要把每个相同高度的地方先染色,然后暴力从高往低连边,统计入度和出度的个数。最后统计入度为0的颜色数和出度为0的颜色数,比一个max即可。 下面放上简单易懂的代码。 code #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<queue> #include<map> using namespace std; const

Span attribute on colgroup and col

帅比萌擦擦* 提交于 2019-11-30 19:01:01
问题 Are these codes logically equivalent? <colgroup span="7"> </colgroup> And <col span="7" /> And <colgroup> <col /> <col /> <col /> <col /> <col /> <col /> <col /> </colgroup> Will any attributes via HTML or properties via CSS have equal effect? Can sombody also add "colgroup" Tag. No enough rep for me to do that. 回答1: From the specification for <col>: Contexts in which this element can be used: As a child of a colgroup element that doesn't have a span attribute. [...] Content attributes:

Python-工具-生成测试数据

筅森魡賤 提交于 2019-11-30 18:35:26
在日常开发测试中,可能需要测试SQL执行性能,但是一般在开发环境中不存在测试所需的数据,因为生产环境的数据是有法律效益的,非法获取会触犯法律。 所以在平时的工作中只能自己根据数据标准造数据,为了避免重复编写造数脚本,编写了一个通用Python脚本。 import cx_Oracle import string import random def id_generator(size=6, chars=string.ascii_uppercase + string.digits): return ''.join(random.choice(chars) for _ in range(size)) db=cx_Oracle.connect('用户名/密码@服务名') dbcursor = db.cursor() sql1 = 'insert into ' sql2 = ' values( ' bl = True while(bl==True): treemenuname = input('请输表名,0 退出\n') sql1 = sql1 + treemenuname + '(' num = input('请输生成条数,0 退出\n') dbcursor.execute("select col.column_name from user_constraints con, user

8.27

南笙酒味 提交于 2019-11-30 18:22:26
规定Ci,j=Ai×BjC_{i,j}=A_i\times B_jCi,j​=Ai​×Bj​。 现在你需要求出这个矩阵的最大子矩阵的和(即该子矩阵的权值和是所有子矩阵里面最大的)。 D 矩阵 题解 对于10%,很明显是个O(n^6 )的算法..那么直接暴力枚举两个端点,然后暴力统计和取max即可。 对于30%,注意到这个矩阵的生成方式有点特别,把它写出来,就会发现一个矩阵的和是一段Ai乘上一段Bj,那么便可以省去统计两重循环,复杂度O(n^4) 对于50%,考虑优化30分的做法,30分的统计就是一个前缀和相乘的形式,那么要让它最大无非3种情况: 正数最大×正数最大; 负数最小×负数最小; 正数最小×负数最大,第三种又可以分为正数最小在A中,正数最小在B中两种情况,于是维护前缀max⁡和前缀min⁡,分类讨论一下,就可以O(n^2)解决了。 对于100%,既然是一段Ai乘上一段Bj,那么分别统计最大子段和和最小子段和即可。 复杂度O(n) 至于怎么算最小子段和?全部取反求最大子段和再重新取反即可。 #define N 1000010 #define M int f[N],a[N],b[N],ans,tmp1,tmp2,tmp3,tmp4; int n,m; int solve(int a[],int n){ int res=-2e18; rep(i,1,n)f[i]=max(a[i]

Write a data frame to csv file without column header in R [duplicate]

末鹿安然 提交于 2019-11-30 14:27:12
问题 This question already has answers here : Export CSV without col.names (3 answers) Closed 4 years ago . I would like to store the contents of my data frame into a .csv file without the names of columns. I use the following piece of code, write.csv(cur_data,new_file, row.names = F, col.names=F) The resulting file looks like this, "V1","V2" -0.02868862,5.442283e-11 -0.03359281,7.669754e-12 -0.03801883,-1.497323e-10 -0.04320051,-6.557672e-11 However I would like to have the file in the following

软件工程第三次作业---数独

≡放荡痞女 提交于 2019-11-30 11:29:10
软件工程第三次作业---数独 一. GitHub地址 二.PSP表格 PSP2.1 Personal Software Process Stages 预估耗时(分钟) Planning 计划 60 Estimate 估计这个任务需要多少时间 2100 Development 开发 2100 Analysis 需求分析(包括学新技术) 480 Design Spec 生成设计文档 30 Design Review 设计复审 30 Coding Standard 代码规范(为目前的开发指定合适的规范) 30 Design 具体设计 60 Coding 具体编码 900 Code Review 代码复审 30 Test 测试(自我测试,修改代码,提交修改) 120 Reporting 报告 240 Test Repor 测试报告 120 Size Measurement 计算工作量 30 Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划 240 合计 2100 三.解题思路 拿到这道题,首先想到的是我长到这么大竟然没有做过一张数独?(小羞耻。。)那么我首先要做的一步就是了解数独规则。 1.了解规则 百度百科简介: 数独盘面是个九宫,每一宫又分为九个小格。在这八十一格中给出一定的已知数字和解题条件,利用逻辑和推理

软件工程实践2019第三次作业

萝らか妹 提交于 2019-11-30 11:06:18
GitHub项目地址: https://github.com/fishred2941214/2019SoftwareEngineer/tree/master/031702409/src PSP表格: PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟) Planning 计划 1小时 0.5小时 Estimate 估计这个任务需要多少时间 33小时 36小时 Development 开发 8小时 10小时 Analysis 需求分析 (包括学习新技术) 8小时 7小时 Design Spec 生成设计文档 1小时 1.5小时 Design Review 设计复审 0.5小时 0.5小时 Coding Standard 代码规范 (为目前的开发制定合适的规范) 1小时 0.5小时 Design 具体设计 2小时 1小时 Coding 具体编码 5小时 7小时 Code Review 代码复审 2小时 1小时 Test 测试(自我测试,修改代码,提交修改) 1小时 2小时 Reporting 报告 2小时 3小时 Test Repor 测试报告 1小时 1小时 Size Measurement 计算工作量 0.5小时 0.5小时 Postmortem & Process Improvement Plan 事后总结,