R自动数据收集第二章HTML笔记1(主要关于handler处理器函数和帮助文档所有示例)
1在chrome(chrome的效果相对比用360极速好,虽然内核一致),选中一行文本,右键检查(inspect),就可以选中对应的那一行HTML源码
url <-"http://www.r-datacollection.com/materials/html/fortunes.html"
> fortunes <- readLines(con = url)
> fortunes
[1]"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">"
[2]"<html> <head>"
[3]"<title>Collected R wisdoms</title>"
[4]"</head>"
[5]""
[6]"<body>"
[7]"<div id=\"R Inventor\" lang=\"english\" date=\"June/2003\">"
[8]" <h1>Robert Gentleman</h1>"
[9]" <p><i>'What we have is nice, but we need something very different'</i></p>"
[10]" <p><b>Source: </b>Statistical Computing 2003, Reisensburg"
[11]"</div>"
[12]""
[13]"<div lang=english date=\"October/2011\">"
[14]" <h1>Rolf Turner</h1>"
[15]" <p><i>'R is wonderful, but it cannot work magic'</i> <br><emph>answering a request for automatic generation of 'data from a known mean and 95% CI'</emph></p>"
[16]" <p><b>Source: </b><a href=\"https://stat.ethz.ch/mailman/listinfo/r-help\">R-help</a></p>"
[17]"</div>"
[18]""
[19]"<address><a href=\"www.r-datacollectionbook.com\"><i>The book homepage</i><a/></address>"
[20]""
[21]"</body> </html>"
> library(XML)
> parsed_fortunes <- htmlParse(file = url)
>print(parsed_fortunes)
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head><title>Collected R wisdoms</title></head>
<body>
<divid="R Inventor"lang="english"date="June/2003">
<h1>Robert Gentleman</h1>
<p><i>'What we have is nice, but we need something very different'</i></p>
<p><b>Source: </b>Statistical Computing 2003, Reisensburg
</p>
</div>
<divlang="english"date="October/2011">
<h1>Rolf Turner</h1>
<p><i>'R is wonderful, but it cannot work magic'</i><br><emph>answering a request for automatic generation of 'data from a known mean and 95% CI'</emph></p>
<p><b>Source: </b><ahref="https://stat.ethz.ch/mailman/listinfo/r-help">R-help</a></p>
</div>
<address>
<ahref="www.r-datacollectionbook.com"><i>The book homepage</i></a><a></a>
</address>
</body>
</html>
#代码片段3
h1 <- list("body"= function(x){NULL})
parsed_fortunes <- htmlTreeParse(url, handlers = h1, asTree = TRUE)
parsed_fortunes$children
# $html
# <html>
# <head>
# <title>Collected R wisdoms</title>
# </head>
# </html>
h2 <- list(
startElement = function(node,...){
name <- xmlName(node)
if(name %in% c("div","title")){NULL}else{node}
},
comment = function(node){NULL}
)
parsed_fortunes <- htmlTreeParse(file = url, handlers = h2, asTree = TRUE)
parsed_fortunes$children
$html
<html>
<head/>
<body>
<address>
<ahref="www.r-datacollectionbook.com">
<i>The book homepage</i>
</a>
<a/>
</address>
</body>
</html>
h1 <- list("body"= function(x){
print('here is a body tag')
NULL
})
parsed_fortunes <- htmlTreeParse(url, handlers = h1, asTree = TRUE)
[1] "here is a body tag"
i <-0
h2 <- list(
startElement = function(node,...){
i <<- i +1
print(paste("here is the ",i,"st tag,its name is",xmlName(node)))
NULL
}
# comment = function(node){
# print(paste("here is a comment,its name is",xmlName(node)))
# NULL
# }
)
parsed_fortunes <- htmlTreeParse(file = url, handlers = h2, asTree = TRUE)
[1]"here is the 1 st tag,its name is title"
[1]"here is the 2 st tag,its name is head"
[1]"here is the 3 st tag,its name is h1"
[1]"here is the 4 st tag,its name is i"
[1]"here is the 5 st tag,its name is p"
[1]"here is the 6 st tag,its name is b"
[1]"here is the 7 st tag,its name is p"
[1]"here is the 8 st tag,its name is div"
[1]"here is the 9 st tag,its name is h1"
[1]"here is the 10 st tag,its name is i"
[1]"here is the 11 st tag,its name is br"
[1]"here is the 12 st tag,its name is emph"
[1]"here is the 13 st tag,its name is p"
[1]"here is the 14 st tag,its name is b"
[1]"here is the 15 st tag,its name is a"
[1]"here is the 16 st tag,its name is p"
[1]"here is the 17 st tag,its name is div"
[1]"here is the 18 st tag,its name is i"
[1]"here is the 19 st tag,its name is a"
[1]"here is the 20 st tag,its name is a"
[1]"here is the 21 st tag,its name is address"
[1]"here is the 22 st tag,its name is body"
[1]"here is the 23 st tag,its name is html"
getItalics = function(){
i_container = character()
list(i = function(node,...){
i_container <<- c(i_container, xmlValue(node))
}, returnI = function() i_container)
}
h3 <- getItalics()
invisible(htmlTreeParse(url, handlers = h3))
h3$returnI()
[1]"'What we have is nice, but we need something very different'"
[2]"'R is wonderful, but it cannot work magic'"
[3]"The book homepage"
> a = character()
> b<-c(a,'2')
> b
[1]"2"
> c<-c(b,'3')
> c
[1]"2""3"
> a
character(0)
> b
[1]"2"
这样的写法也很神奇?
name The name of the element.attributes For regular elements, a named list of XML attributes converted from the <tag x="1" y="abc">children List of sub-nodes.value Used only for text entries.Some nodes specializations of XMLNode, such as XMLComment, XMLProcessingInstruction, XMLEntityRef are used.
<?xml version="1.0"?>
<!DOCTYPE foo [
<!ENTITY % bar "for R and S">
<!ENTITY % foo "for Omegahat">
<!ENTITY testEnt "test entity bar">
<!ENTITY logo SYSTEM "images/logo.gif" NDATA gif>
<!ENTITY % extEnt SYSTEM "http://www.omegahat.net"><!-- include the contents of the README file in the same directory as this one. -->
<!ELEMENT x (#PCDATA) >
<!ELEMENT y (x)* >
]>
<!-- A comment -->
<foox="1">
<elementattrib1="my value"/>
&testEnt;
<?R sum(rnorm(100))?>
<a>
<!-- A comment -->
<b>
%extEnt;
</b>
</a>
<![CDATA[
This is escaped data
containing < and &.
]]>
Note that this caused a segmentation fault if replaceEntities was
not TRUE.
That is,
<code>
xmlTreeParse("test.xml", replaceEntities = TRUE)
</code>
works, but
<code>
xmlTreeParse("test.xml")
</code>
does not if this is called before the one above.
This is now fixed and was caused by
treating an xmlNodePtr in the C code
that had type XML_ELEMENT_DECL
and so was in fact an xmlElementPtr.
Aaah, C and casting!
</foo>
fileName <- system.file("exampleData","test.xml", package="XML")
# parse the document and return it in its standard format.
xmlTreeParse(fileName)
# parse the document, discarding comments.
xmlTreeParse(fileName, handlers=list("comment"=function(x,...){NULL}), asTree = TRUE)
这没什么好说的
# print the entities
invisible(xmlTreeParse(fileName,
handlers=list(entity=function(x){
cat("In entity",x$name, x$value,"\n")
x}
), asTree = TRUE
)
)
# Parse some XML text.
# Read the text from the file
xmlText <- paste(readLines(fileName),"\n", collapse="")
print(xmlText)
xmlTreeParse(xmlText, asText=TRUE)
# with version 1.4.2 we can pass the contents of an XML
# stream without pasting them.
xmlTreeParse(readLines(fileName), asText=TRUE)
# Read a MathML document and convert each node
# so that the primary class is
# <name of tag>MathML
# so that we can use method dispatching when processing
# it rather than conditional statements on the tag name.
# See plotMathML() in examples/.
fileName <- system.file("exampleData","mathml.xml",package="XML")
m <- xmlTreeParse(fileName,
handlers=list(
startElement = function(node){
cname <- paste(xmlName(node),"MathML", sep="",collapse="")
class(node)<- c(cname,class(node));
node
}))
这个功能有点意思,修改node的属性,将其第一个属性修改为标签名+MathML,之前的属性紧随其后,这样当我们调用的时候,就可以自动根据“标签名+MathML”属性调用泛型函数中对应的函数,这样就避免了我们还有使用if分支结构去筛选调用相应的方法。
# In this example, we extract _just_ the names of the
# variables in the mtcars.xml file.
# The names are the contents of the <variable>
tags.- # We discard all other tags by returning NULL
# from the startElement handler.
#
# We cumulate the names of variables in a character
vector named `vars'.# We define this within a closure and define the
# variable function within that closure so that it
# will be invoked when the parser encounters a <variable>
tag.# This is called with 2 arguments: the XMLNode object (containing
its children) and- # the list of attributes.
# We get the variable name via call to xmlValue().
# Note that we define the closure function in the call and then
# create an instance of it by calling it directly as
# (function() {...})()
# Note that we can get the names by parsing
# in the usual manner and the entire document and then executing
# xmlSApply(xmlRoot(doc)[[1]], function(x) xmlValue(x[[1]]))
# which is simpler but is more costly in terms of memory.
fileName <- system.file("exampleData","mtcars.xml", package="XML")
doc <- xmlTreeParse(fileName,
handlers =(function(){
vars <- character(0);
list(
variable=function(x, attrs){
vars <<- c(vars, xmlValue(x[[1]]));
print(vars)
},
startElement=function(x,attr){
NULL
},
names = function(){
vars
}
)
})()
)
[1]"mpg"
[1]"mpg""cyl"
[1]"mpg" "cyl" "disp"
[1]"mpg" "cyl" "disp""hp"
[1]"mpg" "cyl" "disp""hp" "drat"
[1]"mpg" "cyl" "disp""hp" "drat""wt"
[1]"mpg" "cyl" "disp""hp" "drat""wt" "qsec"
[1]"mpg" "cyl" "disp""hp" "drat""wt" "qsec""vs"
[1]"mpg" "cyl" "disp""hp" "drat""wt" "qsec""vs" "am"
[1]"mpg" "cyl" "disp""hp" "drat""wt" "qsec""vs" "am" "gear"
[1]"mpg" "cyl" "disp""hp" "drat""wt" "qsec""vs" "am" "gear""carb"
# Here we just print the variable names to the console
# with a special handler.
doc <- xmlTreeParse(fileName, handlers = list(
variable=function(x, attrs){
print(xmlValue(x[[1]])); TRUE
}), asTree=TRUE)
doc <- xmlTreeParse(fileName,
handlers = list(variable=function(x, attrs){
print(xmlValue(x[[1]]))
})
)
[1]"mpg"
[1]"cyl"
[1]"disp"
[1]"hp"
[1]"drat"
[1]"wt"
[1]"qsec"
[1]"vs"
[1]"am"
[1]"gear"
[1]"carb"
try(xmlTreeParse(
system.file("exampleData","TestInvalid.xml", package="XML"),
validate=TRUE))
# Parse an XML document directly from a URL.
# Requires Internet access.
xmlTreeParse("http://www.omegahat.net/Scripts/Data/mtcars.xml", asText=TRUE)
Error: XML content does not seem to be XML:'http://www.omegahat.net/Scripts/Data/mtcars.xml'
counter = function(){
counts = integer(0)
list(startElement = function(node){
name = xmlName(node)
if(name %in% names(counts))
else
counts[name]<<-1
},
counts = function() counts)
}
h = counter()
invisible(xmlParse(system.file("exampleData","mtcars.xml", package="XML"),
handlers = h)
)
h$counts()
variable variables record dataset
22 2 64 2
getLinks = function(){
links = character()
list(a = function(node,...){
links <<- c(links, xmlGetAttr(node,"href"))
node
},
links = function()links)
}
h1 = getLinks()
invisible(htmlTreeParse(system.file("examples","index.html", package ="XML"),
handlers = h1))
h1$links()
[1]"XML_0.97-0.tar.gz"
[2]"XML_0.97-0.zip"
[3]"XML_0.97-0.tar.gz"
[4]"XML_0.97-0.zip"
[5]"Overview.html"
[6]"manual.pdf"
[7]"Tour.pdf"
[8]"description.pdf"
[9]"WritingXML.html"
[10]"FAQ.html"
[11]"Changes"
[12]"http://cm.bell-labs.com/stat/duncan"
[13]"mailto:duncan@wald.ucdavis.edu"
h2 = getLinks()
htmlTreeParse(system.file("examples","index.html", package ="XML"),
handlers = h2, useInternalNodes = TRUE)
all(h1$links()== h2$links())
[1] TRUE
# Using flat trees
tt = xmlHashTree()
f = system.file("exampleData","mtcars.xml", package="XML")
xmlTreeParse(f, handlers = list(.startElement = tt[[".addNode"]]))
####输出了处理函数本身,加了asTree = TRUE貌似也没效果啊
tt #这个是我自己加的命令
<variable/>
xmlRoot(tt)
<variable/>
>class(tt)
[1]"XMLHashTree" "XMLAbstractDocument"
function (nodes = list(), parents = character(), children = list(),
env = new.env(TRUE, parent = emptyenv()))
{
.count =0
env$.children =.children = new.env(TRUE)
env$.parents =.parents = new.env(TRUE)
f = function(suggestion =""){
if(suggestion ==""|| exists(suggestion, env, inherits = FALSE))
as.character(.count +1)
else suggestion
}
assign(".nodeIdGenerator", f, env)
addNode = function(node, parent = character(),..., attrs = NULL,
namespace = NULL, namespaceDefinitions = character(),
.children = list(...), cdata = FALSE, suppressNamespaceWarning = getOption("suppressXMLNamespaceWarning",
FALSE)){
if(is.character(node))
node = xmlNode(node, attrs = attrs, namespace = namespace,
namespaceDefinitions = namespaceDefinitions)
.kids =.children
.children =.this$.children
node = asXMLTreeNode(node,.this, className ="XMLHashTreeNode")
id = node$id
assign(id, node, env)
.count <<-.count +1
if(!inherits(parent,"XMLNode")&&(!is.environment(parent)&&
length(parent)==0)|| parent =="")
return(node)
if(inherits(parent,"XMLHashTreeNode"))
parent = parent$id
if(length(parent)){
assign(id, parent, envir =.parents)
if(exists(parent,.children, inherits = FALSE))
tmp = c(get(parent,.children), id)
else tmp = id
assign(parent, tmp,.children)
}
return(node)
}
env$.addNode <- addNode
.tidy = function(){
idx <- idx -1
length(nodeSet)<- idx
length(nodeNames)<- idx
names(nodeSet)<- nodeNames
.nodes <<- nodeSet
idx
}
.this = structure(env,class= oldClass("XMLHashTree"))
.this
}
f = system.file("exampleData","mtcars.xml", package="XML")
doc = xmlTreeParse(f, useInternalNodes = TRUE)
sapply(getNodeSet(doc,"//variable"), xmlValue)
[1]"mpg" "cyl" "disp""hp" "drat""wt" "qsec""vs" "am"
[10]"gear""carb"
# character set encoding for HTML
f = system.file("exampleData","9003.html", package ="XML")
# we specify the encoding
d = htmlTreeParse(f, encoding ="UTF-8")
# get a different result if we do not specify any encoding
d.no = htmlTreeParse(f)
# document with its encoding in the HEAD of the document.
d.self = htmlTreeParse(system.file("exampleData","9003-en.html",package ="XML"))
# XXX want to do a test here to see the similarities between d and
# d.self and differences between d.no
关于编码解码
<xxmlns:xinclude="http://www.w3.org/2001/XInclude">
<!-- Simple test of including a set of nodes from an XML document -->
<xinclude:includehref="something.xml#xpointer(//p)"/>
</x>
<xxmlns:xinclude="http://www.w3.org/2001/XInclude">
<!-- Simple test of including a set of nodes from an XML document -->
<xinclude:includehref="doesnt_exist.xml#xpointer(//p)">
<xinclude:fallback>
Some <i>fallback text</i></xinclude:fallback>
</xinclude:include>
</x>
# include
f = system.file("exampleData","nodes1.xml", package ="XML")
xmlRoot(xmlTreeParse(f, xinclude = FALSE))
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
<!--Simple test of including a set of nodes from an XML document-->
<xinclude:include href="something.xml#xpointer(//p)"/>
</x>
xmlRoot(xmlTreeParse(f, xinclude = TRUE))
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
<!--Simple test of including a set of nodes from an XML document-->
<p ID="author">something</p>
<p>really</p>
<p>simple</p>
</x>
f = system.file("exampleData","nodes2.xml", package ="XML")
xmlRoot(xmlTreeParse(f, xinclude = TRUE))
failed to load external entity "D:/RSets/R-3.3.2/library/XML/exampleData/doesnt_exist.xml"
<x xmlns:xinclude="http://www.w3.org/2001/XInclude">
<!--Simple test of including a set of nodes from an XML document-->
Some
<i>fallback text</i>
</x>
<doc>
<pID="author">something</p>
<p>really</p>
<foo>bar</foo>
<p>simple</p>
</doc>
try(xmlTreeParse("<doc><a> & < <?pi ></doc>"))
xmlParseEntityRef: no name
StartTag: invalid element name
ParsePI: PI pi never end ...
Premature end of data in tag a line 1
Premature end of data in tag doc line 1
Error : 1: xmlParseEntityRef: no name
2: StartTag: invalid element name
3: ParsePI: PI pi never end ...
4: Premature end of data in tag a line 1
5: Premature end of data in tag doc line 1
tryCatch(xmlTreeParse("<doc><a> & < <?pi > </doc>"),
"XMLParserErrorList"= function(e){
cat("Errors in XML document\n", e$message,"\n")
}
)
xmlParseEntityRef: no name
StartTag: invalid element name
ParsePI: PI pi never end ...
Premature end of data in tag a line 1
Premature end of data in tag doc line 1
Error : in XML document
1: xmlParseEntityRef: no name
2: StartTag: invalid element name
3: ParsePI: PI pi never end ...
4: Premature end of data in tag a line 1
5: Premature end of data in tag doc line 1
try(xmlTreeParse("<doc><a> & < <?pi > </doc>", error = NULL))
Error: xmlParseEntityRef: no name
f = system.file("exampleData","book.xml", package ="XML")
doc.trim = xmlInternalTreeParse(f, trim = TRUE)
doc = xmlInternalTreeParse(f, trim = FALSE)
xmlSApply(xmlRoot(doc.trim),class)
chapter chapter
[1,]"XMLInternalElementNode""XMLInternalElementNode"
[2,]"XMLInternalNode" "XMLInternalNode"
[3,]"XMLAbstractNode" "XMLAbstractNode"
xmlSApply(xmlRoot(doc),class)
text chapter
[1,]"XMLInternalTextNode""XMLInternalElementNode"
[2,]"XMLInternalNode" "XMLInternalNode"
[3,]"XMLAbstractNode" "XMLAbstractNode"
text chapter
[1,]"XMLInternalTextNode""XMLInternalElementNode"
[2,]"XMLInternalNode" "XMLInternalNode"
[3,]"XMLAbstractNode" "XMLAbstractNode"
text
[1,]"XMLInternalTextNode"
[2,]"XMLInternalNode"
[3,]"XMLAbstractNode"
神奇的是,xmlInternalTreeParse函数虽然也在该帮助文档页面,但是一点相关的说明都没有....
f = system.file("exampleData","book.xml", package ="XML")
titles = list()
xmlTreeParse(f, handlers = list(title = function(x)
]]<<- x))
$title #此为输出
function (x)
titles[[length(titles)+1]]<<- x
sapply(titles, xmlValue)
[1]"XML"
[2]"The elements of an XML document"
[3]"Parsing XML"
[4]"DOM"
[5]"SAX"
[6]"XSL"
[7]"templates"
[8]"XPath expressions"
[9]"named templates"
rm(titles)
附件列表
R自动数据收集第二章HTML笔记1(主要关于handler处理器函数和帮助文档所有示例)的更多相关文章
- R自动数据收集第二章HTML笔记2(主要关于htmlTreeParse函数)
包含以下几个小的知识点 1htmlTreeParse函数源码和一些参数 2hander的写法 3关于missing函数 4关于if-else语句中else语句的花括号问题 5关于checkHandle ...
- R自动数据收集第一章概述——《List of World Heritage in Danger》
导包 library(stringr) library(XML) library(maps) heritage_parsed <- htmlParse("http://en ...
- AS开发实战第二章学习笔记——其他
第二章学习笔记(1.19-1.22)像素Android支持的像素单位主要有px(像素).in(英寸).mm(毫米).pt(磅,1/72英寸).dp(与设备无关的显示单位).dip(就是dp).sp(用 ...
- #Spring实战第二章学习笔记————装配Bean
Spring实战第二章学习笔记----装配Bean 创建应用对象之间协作关系的行为通常称为装配(wiring).这也是依赖注入(DI)的本质. Spring配置的可选方案 当描述bean如何被装配时, ...
- CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令
相关文章链接 CentOS6安装各种大数据软件 第一章:各个软件版本介绍 CentOS6安装各种大数据软件 第二章:Linux各个软件启动命令 CentOS6安装各种大数据软件 第三章:Linux基础 ...
- Machine Learning In Action 第二章学习笔记: kNN算法
本文主要记录<Machine Learning In Action>中第二章的内容.书中以两个具体实例来介绍kNN(k nearest neighbors),分别是: 约会对象预测 手写数 ...
- Day2 《机器学习》第二章学习笔记
这一章应该算是比价了理论的一章,我有些概率论基础,不过起初有些地方还是没看多大懂.其中有些公式的定义和模型误差的推导应该还是很眼熟的,就是之前在概率论课上提过的,不过有些模糊了,当时课上学得比较浅. ...
- Python核心编程第三版第二章学习笔记
第二章 网络编程 1.学习笔记 2.课后习题 答案是按照自己理解和查阅资料来的,不保证正确性.如由错误欢迎指出,谢谢 1. 套接字:A network socket is an endpoint of ...
- Linux第一章第二章学习笔记
第一章 Linux内核简介 1.1 Unix的历史 它是现存操作系统中最强大最优秀的系统. 设计简洁,在发布时提供原代码. 所有东西都被当做文件对待. Unix的内核和其他相关软件是用C语言编写而成的 ...
随机推荐
- WPF 自定义标题栏 自定义菜单栏
自定义标题栏 自定义列表,可以直接修改WPF中的ListBox模板,也用这样类似的效果.但是ListBox是不能设置默认选中状态的. 而我们需要一些复杂的UI效果,还是直接自定义控件来的快 GitHu ...
- PL/SQL配置Oracle数据库路径
打开PL/SQL-Tools->Preferences-Orcacle->Connecttion 找到配置路径,打开-product\instantclient_11_2\NETWORK\ ...
- zip命令的基本用法
zip命令的基本用法是: zip [参数] [打包后的文件名] [打包的目录路径] linux zip命令参数列表: -a 将文件转成ASCII模式 -F 尝试修复损坏的压缩文件 -h 显示帮助界面 ...
- [转]Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on (C#)
本文转自:https://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-o ...
- 【译】什么是 web 框架?
Web 应用框架,或者简单的说是“Web 框架”,其实是建立 web 应用的一种方式.从简单的博客系统到复杂的富 AJAX 应用,web 上每个页面都是通过写代码来生成的.我发现很多人都热衷于学习 w ...
- heredoc技术
Heredoc技术,在正规的PHP文档中和技术书籍中一般没有详细讲述,只是提到了这是一种Perl风格的字符串输出技术.但是现在的一些论坛程序,和部分文章系统,都巧妙的使用heredoc技术,来部分的实 ...
- Ubuntu apache2.4 设置虚拟主机
每次重装系统如何配置都上网找,搞半天,都是不对的,还不如自己记下来,以作参考呢.我的项目目录是 /home/feiffy/demo/test,映射的域名是 test.com,这样在浏览器输入 test ...
- 延迟加载外部js文件,延迟加载图片(jquery.lazyload.js和echo,js)
js里一说到延迟加载,大都离不开两种情形,即外部Js文件的延迟加载,以及网页图片的延迟加载: 1.首先简单说一下js文件的3种延迟加载方式: (1)<script type="text ...
- mybatis返回数据类型为map,值为null的key没返回
创建mybatis-config.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE ...
- 【USACO 3.2】Spinning Wheels(同心圆旋转)
题意: 5个同心圆,告诉你角速度,每个圆有1至5个楔,告诉你起点和宽度.求最早时间如果有的话使得存在某个角度经过5个圆的楔. 题解: 最重要的是要意识到,360秒钟后,每个圆都回到了原来的位置. 我的 ...