line

POJ - 3525 E - Most Distant Point from the Sea(半平面交+二分)

浪尽此生 提交于 2020-02-01 22:05:25
POJ - 3525 E - Most Distant Point from the Sea 题意:给你一个日本, 日本中有一个地方, 离海的最近距离比其他地方的最近距离都大.要你求该地到海的最近距离. 也就是给你一个凸包, 在里面放一个最大的圆, 求出圆的半径 解法: 可以二分半径 每次将所有线段向圆心平移mid个单位长度 如果还存在核,则l=mid,否则r=mid 代码: # include <cmath> # include <cstdio> # include <cstring> # include <algorithm> using namespace std ; const int MAXN = 1e3 + 5 ; const double EPS = 1e-9 ; const double PI = acos ( - 1 ) ; inline int sgn ( double a ) { return a < - EPS ? - 1 : a > EPS ; } inline int cmp ( double a , double b ) { return sgn ( a - b ) ; } int n , m , T ; struct Point ; struct Line ; typedef Point Vector ; struct Point { double

CSV格式数据清洗

十年热恋 提交于 2020-02-01 01:09:03
描述 附件是一个CSV文件,其中每个数据前后存在空格,请对其进行清洗,要求如下:‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬ (1)去掉每个数据前后空格,即数据之间仅用逗号(,)分割;‪‬‪‬‪‬‪‬‪‬‮‬‪‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‫‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‭‬‪‬‪‬‪‬‪‬‪‬‮‬‫‬‮‬‪‬‪‬‪‬‪‬‪‬‮‬‪‬‪‬ (2)清洗后打印输出。 输入输出示例 附件 见附录 代码 fo = open ( "data.csv" ) for line in fo : line = line . replace ( " " , "" ) print ( line , end = "" ) 来源: CSDN 作者: 赖亦无 链接: https://blog.csdn.net/weixin_43012724/article/details/103655209

【算法学习记录-排序题】【PAT A1016】Phone Bills

爷,独闯天下 提交于 2020-01-31 17:57:16
A long-distance telephone company charges its customers by the following rules: Making a long-distance call costs a certain amount per minute, depending on the time of day when the call is made. When a customer starts connecting a long-distance call, the time will be recorded, and so will be the time when the customer hangs up the phone. Every calendar month, a bill is sent to the customer for each minute called (at a rate determined by the time of day). Your job is to prepare the bills for each month, given a set of phone call records. Input Specification: Each input file contains one test

P3222 [HNOI2012]射箭

限于喜欢 提交于 2020-01-31 10:51:43
题意 考虑二分答案,我们只需要判断是否存在 \((a,b)\) ,对于任意 \(i\in[1,mid]\) 满足 \(ax_i^2+bx_i\in[y_{1i},y_{2i}]\) 。 展开可得: \(\frac{y_{1i}}{x_i}\leqslant ax_i+b\leqslant\frac{y_{2i}}{x_i}\) 即: \(ax_i+b-\frac{y_{1i}}{x_i}\geqslant 0\) \(ax_i+b-\frac{y_{12}}{x_i}\leqslant 0\) 将 \(a,b\) 当成 \(x,y\) ,这是两条直线,我们半平面交判断即可。 然后这题卡精度卡了我一下午,我也是真有耐心。 code: #include<bits/stdc++.h> using namespace std; #define double long double const int maxn=100010; const double eps=1e-18; const double inf=1e12; int n,m; struct Point { double x,y; inline double len(){return sqrt(x*x+y*y);} Point operator+(const Point a)const{return (Point){x+a.x,y

python_矩阵转置

百般思念 提交于 2020-01-30 09:46:10
矩阵转置 """ 矩阵转置 算法:将list01中每列,存储到list02中每行 """ list01 = [ [ 1 , 2 , 3 , 4 ] , [ 5 , 6 , 7 , 8 ] , [ 9 , 10 , 11 , 12 ] , ] list02 = [ ] for c in range ( len ( list01 [ 0 ] ) ) : line = [ ] for r in range ( len ( list01 ) ) : line . append ( list01 [ r ] [ c ] ) list02 . append ( line ) print ( list02 ) 来源: CSDN 作者: 李富贵︴ 链接: https://blog.csdn.net/weixin_46198526/article/details/104108245

What JavaScript code would I use to plot a trend line?

只谈情不闲聊 提交于 2020-01-30 08:17:25
问题 Assuming that I have the following values that I'm going to plot on a Line chart (these are values and not coordinates - the coordinates are calculated by my software and are shown below): [4,4,3,2,5,5] How would I turn those values into a set of trendline values/coordinates? (BTW I don't really have any Maths expertise beyond school level - so no fancy Maths terminology please!). To add further details: These are a set of values that are spaced equally across a 500 pixel space (an HTML5

pat乙1024 科学计数法

泄露秘密 提交于 2020-01-30 08:06:37
# include <iostream> # include <cstring> using namespace std ; bool isnumber ( char c ) //判断是否为数字 { if ( c >= '0' && c <= '9' ) return true ; else return false ; } int main ( ) { string line ; getline ( cin , line ) ; int flag = 1 , flag1 , flag2 , e = 0 , n , i = 0 , now ; int len = line . length ( ) ; if ( line [ 0 ] == '+' ) flag1 = 1 ; //第一位为底数符号 else flag1 = 0 ; line . erase ( line . begin ( ) ) ; while ( i < len ) //处理字符串 { if ( flag && isnumber ( line [ i ] ) ) //保留数字 { i ++ ; } else if ( line [ i ] == '.' ) //去掉小数点 { line . erase ( line . begin ( ) + i ) ; } else if ( line [ i ] == 'E'

Is it possible to change ONE line in a txt file WITHOUT reading and writing the whole file (Java)?

筅森魡賤 提交于 2020-01-30 04:45:32
问题 Say I have a text file: I love bananas. <age> 23 </age> years old. I like beaches. All I want to do is open said file and change the age to 24 or 25. Any way to do that in Java WITHOUT reading a writing the whole file? I know its possible with buffered reader and writer, but I am looking for a less memory intensive way when the file gets to be huge. 回答1: Short answer: no. Long answer: Not really. If you know that the text you're inserting directly replaces the text you're removing you could

java读取网页内容

半城伤御伤魂 提交于 2020-01-30 02:57:52
package com.linxinxin.tools;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.IOException;import java.io.InputStreamReader;import java.net.MalformedURLException;import java.net.URL;public class CrawlerUtil { public static void main(String[] a){ try { URL url=new URL("http://www.baidu.com"); BufferedReader reader=new BufferedReader(new InputStreamReader(url.openStream())); BufferedWriter writer=new BufferedWriter(new FileWriter("index.html")); String line; while((line=reader.readLine())!=null){ System.out.println(line); writer.write(line);

C语言程序设计 第三章 运算符与表达式 知识总结

喜欢而已 提交于 2020-01-29 18:58:14
运算符的定义 运算符是一种告诉编译器执行特定的数学或逻辑操作的符号。C 语言内置了丰富的运算符,并提供了以下类型的运算符: ①  算术运算符 ②  关系运算符 ③  逻辑运算符 ④ 位运算符 ⑤  赋值运算符 ⑥ 杂项运算符 加粗部分是C语言程序设计第3版的教学内容 算数运算符 实例: # include <stdio.h> int main ( ) { int a = 21 ; int b = 10 ; int c ; c = a + b ; printf ( "Line 1 - c 的值是 %d\n" , c ) ; c = a - b ; printf ( "Line 2 - c 的值是 %d\n" , c ) ; c = a * b ; printf ( "Line 3 - c 的值是 %d\n" , c ) ; c = a / b ; printf ( "Line 4 - c 的值是 %d\n" , c ) ; c = a % b ; printf ( "Line 5 - c 的值是 %d\n" , c ) ; c = a ++ ; // 赋值后再加 1 ,c 为 21,a 为 22 printf ( "Line 6 - c 的值是 %d\n" , c ) ; c = a -- ; // 赋值后再减 1 ,c 为 22 ,a 为 21 printf ( "Line 7 -