2016年4月

一个用流来简化格式化提取的例子

今天遇到跟上学期相似的逗号分隔问题,有了新的思路,mark一下,用流的方法来简化格式化提取,因为流理论上可以重新完整实现读入过程。

题目:
<div id="pageTitle">
<h2>1:There's Treasure Everywhere!</h2>
</div>
<div id="topMenu">

</div>
<div class="problem-page col-9">
<dl class="problem-params">

 <dt>总时间限制:</dt>
 <dd>1000ms</dd>
 <dt>内存限制:</dt>
 <dd>65536kB</dd>

</dl>
<dl class="problem-content">

 <dt>描述</dt>
 <dd>Finding buried treasures is simple: all you need is a map! The pirates in the Caribbean were famous for their enormous buried treasures and their elaborate maps. The maps usually read like ``Start at the lone palm tree. Take three steps towards the forest, then seventeen step towards the small spring, . . . blahblah . . . , finally six steps toward the giant rock. Dig right here, and you will find my treasure!'' Most of these directions just boil down to taking the mentioned number of steps in one of the eight principal compass directions (depicted in the left of the figure).

<!--more-->Obviously, following the paths given by these maps may lead to an interesting tour of the local scenery, but if one is in a hurry, there is usually a much faster way: just march directly from your starting point to the place where the treasure is buried. Instead of taking three steps north, one step east, one step north, three steps east, two steps south and one step west (see figure), following the direct route (dashed line in figure) will result in a path of about 3.6 steps.You are to write a program that computes the location of and distance to a buried treasure, given a 'traditional' map.

<center></center></dd>

 <dd></dd>
 <dd><img class="alignnone" src="https://i.niupic.com/images/2016/06/09/lXnsiL.jpg" width="472" height="201" /></dd>
 <dt>输入</dt>
 <dd>The input contains several strings, each one on a line by itself, and each one consisting of at most 200 characters. The last string will be END, signaling the end of the input. All other strings describe one treasure map each, according to the following format:

The description is a comma-separated list of pairs of lengths (positive integers less than 1000) and directions (N (north), NE (northeast), E (east), SE (southeast), S (south), SW (southwest), W (west) or NW (northwest)). For example, 3W means 3 steps to the west, and 17NE means 17 steps to the northeast. A full stop (.) terminates the description, which contains no blanks.</dd>

 <dt>输出</dt>
 <dd>For every map description in the input, first print the number of the map, as shown in the sample output. Then print the absolute coordinates of the treasure, in the format "The treasure is located at (x,y).". The coordinate system is oriented such that the x-axis points east, and the y-axis points north. The path always starts at the origin (0,0).

On the next line print the distance to that position from the point (0,0), in the format "The distance to the treasure is d.". The fractional values x, y, d must be printed exact to three digits to the right of the decimal point.

Print a blank line after each test case.</dd>

 <dt>样例输入</dt>
 <dd>

10NW.
END</pre>
</dd>

 <dt>样例输出</dt>
 <dd>

The treasure is located at (3.000,2.000).
The distance to the treasure is 3.606.

Map #2
The treasure is located at (-7.071,7.071).
The distance to the treasure is 10.000.
</pre>
</dd>

 <dt>来源</dt>
 <dd>Southwestern European Regional Contest 1997</dd>

</dl>
</div>
















- 阅读剩余部分 -

LaTeX新人教程,30分钟从完全陌生到基本入门[转by nan]

对于真心渴望迅速上手LaTeX的人,前言部分可以跳过不看。

本教程面向对LaTeX完全无认知无基础的新人。
旨在让新人能够用最简单快捷的方式,轻松入门,能够迅速使用LaTeX完成基本的文本编辑。
这个教材最终能够达到的水平是能够使用LaTeX写一篇正常的proposal。如果希望有更大需求的提高,那么推荐在熟悉了这一篇文章的内容之后,再自行google或查阅其他稍厚的教材。
尤其旨在破除部分新人对LaTeX在传闻中难以学习的恐惧感。
在入门之后,面对各种进阶应用、特殊要求与异常状况,可以自行咨询google解决。

- 阅读剩余部分 -

一些数论公式(转)

原文链接:http://blog.sina.com.cn/s/blog_6635898a0100magh.html

以下等式或者不等式均可以用数学归纳法予以证明!

1 + 3 + 5 + ... + (2n - 1) = n^2

1*2 + 2*3 + 3*4 + ... + n*(n + 1) = n*(n + 1)*(n + 2) / 3

1*1! + 2*2! + 3*3! + ... + n*n! = (n + 1)! - 1

1^2 + 2^2 + 3^2 + ... + n^2 = n*(n + 1)*(2n + 1) / 6

1^2 - 2^2 + 3^2 -... + (-1)^n * n^2 = (-1)^(n + 1) * n * (n + 1) / 2

2^2 + 4^2 + ... + (2n)^2 = 2n*(n+1)*(2n+1) / 3

1/2! + 2/3! + ... + n/(n+1)! = 1 - 1/(n+1)!

2^(n + 1) < 1 + (n + 1)2^n

1^3 + 2^3 + 3^3 + ... + n^3 = (n*(n + 1) / 2)^2

1/2n <= 1*3*5*...*(2n-1) / (2*4*6*...*2n) <= 1 / sqrt(n+1)  n=1,2...

2^n >= n^2 , n=4, 5,...

2^n >= 2n + 1, n=3,4,...

r^0 + r^1 + ... + r^n < 1 / (1 - r), n>=0, 0<r<1

1*r^1 + 2*r^2 + ... + n*r^n < r / (1-r)^2, n>=1, 0<r<1

1/2^1 + 2/2^2 + 3/2^3 + ... + n /2^n < 2, n>=1

- 阅读剩余部分 -

对我来说蜜汁WA的冷血格斗场

6:冷血格斗场

总时间限制:
1000ms
内存限制:
65536kB
描述
为了迎接08年的奥运会,让大家更加了解各种格斗运动,facer新开了一家冷血格斗场。格斗场实行会员制,但是新来的会员不需要交入会费,而只要同一名老会员打一场表演赛,证明自己的实力。

我们假设格斗的实力可以用一个正整数表示,成为实力值,两人的实力值可以相同。另外,每个人都有一个唯一的id,也是一个正整数。为了使得比赛更好看,每一个新队员都会选择与他实力最为接近的人比赛,即比赛双方的实力值之差的绝对值越小越好,如果有多个人的实力值与他差别相同,则他会选择id最小的那个。

不幸的是,Facer一不小心把比赛记录弄丢了,但是他还保留着会员的注册记录。现在请你帮facer恢复比赛纪录,按照时间顺序依次输出每场比赛双方的id。

- 阅读剩余部分 -

最新文章

最近回复

分类

归档

其它

微博

基佬们

Fork me on GitHub