7.5 Given two squares on a two-dimensional plane, find a line that would cut these two squares in half. Assume that the top and the bottom sides of the square run parallel to the x-axis 这道题给了我们两个正方形,让我们求一条可以讲这两个正方形平均分为两个部分的直线,前提是两个正方形都和x轴平行.那么我们首先要知道…
7.6 Given a two-dimensional graph with points on it, find a line which passes the most number of points. 这道题给了我们许多点,让我们求经过最多点的一条直线.给之前那道7.5 A Line Cut Two Squares in Half 平均分割两个正方形的直线一样,都需要自己写出点类和直线类.在直线类中,我用我们用斜率和截距来表示直线,为了应对斜率不存在情况,我们还需用一个flag来标记是否…
输入n个点,问可以构成多少个正方形.n,xi,yi<=100,000. 刚看题的时候感觉好像以前见过╮(╯▽╰)╭最近越来越觉得以前见过的题偶尔就出现类似的,可是以前不努力啊,没做出来的没认真研究 首先想到的朴素是n^2的算法,10^10显然不行=.=抱着过预判的侥幸心理写了一发,打算过预判之后锁上看别人代码怎么做,结果TLE 13 第二天早上起来看题解,看不懂,看别人的代码才懂的.... 大概就是,避开最坏情况,枚举正方形左下角的点,然后如果当前x的点数量比sqrt(n)要小,就用当前x的上边…
A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum. Given an grid of integers, how many 3 x 3 "magic square" subgrids are there?  (Each subgrid is co…
1036: [ZJOI2008]树的统计Count Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 8421  Solved: 3439 [Submit][Status][Discuss] Description 一棵树上有n个节点,编号分别为1到n,每一个节点都有一个权值w.我们将以以下的形式来要求你对这棵树完毕一些操作: I. CHANGE u t : 把结点u的权值改为t II. QMAX u v: 询问从点u到点v的路径上的节点的最大权值…
Chapter 1. Arrays and Strings 1.1 Unique Characters of a String 1.2 Reverse String 1.3 Permutation String 1.4 Replace Spaces 1.5 Compress String 1.6 Rotate Image 1.7 Set Matrix Zeroes 1.8 String Rotation Chapter 2. Linked Lists 2.1 Remove Duplicates…
Chapter 1. Arrays and Strings 1.1 Unique Characters of a String 1.2 Reverse String 1.3 Permutation String 1.4 Replace Spaces 1.5 Compress String 1.6 Rotate Image 1.7 Set Matrix Zeroes 1.8 String Rotation Chapter 2. Linked Lists 2.1 Remove Duplicates…
while read line      do            account=`echo "$line"| cut -c1-9`'|'            account+=`echo "$line"| cut -c10-44`'|'            account+=`echo "$line"| cut -c45-45`'|'            account+=`echo "$line"| cut -c…
Kadj Squares Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3594   Accepted: 1456 Description In this problem, you are given a sequence S1, S2, ..., Sn of squares of different sizes. The sides of the squares are integer numbers. We loca…
前言: 公司要统计 treasury库hive表磁盘空间,写了个脚本,如下: 查询hive仓库表占用hdfs文件大小: hadoop fs -du -h  /user/hive/warehouse/treasury.db  > treasury.txt 脚本: #!/bin/sh # while read line do size=$1 num=` echo $line | cut -d " " -f 1` unit=` echo $line | cut -d " &q…