0%

题目链接:HDU 1686

Problem Description

The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter ‘e’. He was a member of the Oulipo group. A quote from the book:

Tout avait Pair normal, mais tout s’affirmait faux. Tout avait Fair normal, d’abord, puis surgissait l’inhumain, l’affolant. Il aurait voulu savoir où s’articulait l’association qui l’unissait au roman : stir son tapis, assaillant à tout instant son imagination, l’intuition d’un tabou, la vision d’un mal obscur, d’un quoi vacant, d’un non-dit : la vision, l’avision d’un oubli commandant tout, où s’abolissait la raison : tout avait l’air normal mais…

Perec would probably have scored high (or rather, low) in the following contest. People are asked to write a perhaps even meaningful text on some subject with as few occurrences of a given “word” as possible. Our task is to provide the jury with a program that counts these occurrences, in order to obtain a ranking of the competitors. These competitors often write very long texts with nonsense meaning; a sequence of 500,000 consecutive ‘T’s is not unusual. And they never use spaces.

So we want to quickly find out how often a word, i.e., a given string, occurs in a text. More formally: given the alphabet {‘A’, ‘B’, ‘C’, …, ‘Z’} and two finite strings over that alphabet, a word W and a text T, count the number of occurrences of W in T. All the consecutive characters of W must exactly match consecutive characters of T. Occurrences may overlap.

阅读全文 »

题目链接:HDU 1711

Problem Description

Given two sequences of numbers : a[1], a[2], …… , a[N], and b[1], b[2], …… , b[M] (1 <= M <= 10000, 1 <= N <= 1000000). Your task is to find a number K which make a[K] = b[1], a[K + 1] = b[2], …… , a[K + M - 1] = b[M]. If there are more than one K exist, output the smallest one.

阅读全文 »

题意

给定一个三角形和一个点 $p$,如果该点不在三角形边上直接输出 $-1$,否则在三角形上找一点 $q$,使得线段 $pq$ 平分三角形面积。

阅读全文 »

题意

王子想要娶公主,但是需要完成一个挑战:在一些房间中找出公主在哪。

每个房间有一个人,他们彼此知道谁在哪个房间。可以问他们三种问题:

  • 你是谁?
  • 在某个房间是谁?
  • 公主在哪个房间?

有三类人,一类一定说真话,一类一定说假话,一类可能说真话可能说假话。

王子知道这三类人的人数分别为 $a$, $b$, $c$,求能否通过问一些问题找到公主在哪,如果能,输出最少需要的问题数。

阅读全文 »

所谓对拍,就是随机生成数据,然后用一个肯定正确的暴力算法的程序,去测试一个要提交的程序。

由于比赛中一般使用 Linux 系统,所以本篇博客的代码都是 Linux 下的程序代码。

其实最简单的方式是写脚本。

这里介绍的是用选手最熟悉的 C++ 语言写对拍程序。

阅读全文 »

ACM-ICPC 现场赛不同的赛站可能比赛环境不同,不过一般都是 Ubuntu 系统。附带的软件可能略有不同,可能会有使用习惯的差异导致效率下降或者无法运行代码,但是在终端下编译运行代码都是相同的。本篇博客介绍的是在终端下如何编辑代码、编译代码、运行代码以及调试代码。

阅读全文 »

题目链接:HDU 5572

Problem Description

On an infinite smooth table, there’s a big round fixed cylinder and a little ball whose volume can be ignored.

Currently the ball stands still at point $A$, then we’ll give it an initial speed and a direction. If the ball hits the cylinder, it will bounce back with no energy losses.

We’re just curious about whether the ball will pass point $B$ after some time.

阅读全文 »

题目链接:HDU 1724

Problem Description

Math is important!! Many students failed in 2+2’s mathematical test, so let’s AC this problem to mourn for our lost youth..

Look this sample picture:

A ellipses in the plane and center in point O. the L,R lines will be vertical through the X-axis. The problem is calculating the blue intersection area. But calculating the intersection area is dull, so I have turn to you, a talent of programmer. Your task is tell me the result of calculations.(defined PI=3.14159265 , The area of an ellipse A=PIab )

阅读全文 »

题目链接:LightOJ - 1248

Description

Given a dice with n sides, you have to find the expected number of times you have to throw that dice to see all its faces at least once. Assume that the dice is fair, that means when you throw the dice, the probability of occurring any face is equal.

For example, for a fair two sided coin, the result is 3. Because when you first throw the coin, you will definitely see a new face. If you throw the coin again, the chance of getting the opposite side is 0.5, and the chance of getting the same side is 0.5. So, the result is

$1 + (1 + 0.5 (1 + 0.5 …))$

$= 2 + 0.5 + 0.5^2 + 0.5^3 + …$

$= 2 + 1 = 3$

阅读全文 »