杰拉斯的博客

[ACM_HDU_2050]折线分割平面

杰拉斯 杰拉斯 | 时间:2012-03-28, Wed | 7,404 views
编程算法 

折线分割平面

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8663 Accepted Submission(s): 6084

Description

我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。

折线分割平面

Input

输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0<n<=10000),表示折线的数量。

Output

对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一行。

(阅读全文…)

[ACM_ZJUT_2012]勘探油田

杰拉斯 杰拉斯 | 时间:2012-03-28, Wed | 6,078 views
编程算法 

勘探油田

Time Limit:1000MS Memory Limit:32768K

Description

某石油勘探公司正在按计划勘探地下油田资源。他们工作在一片长方形的地域中,首先将该地域划分为许多小正方形区域,然后使用探测设备分别探测每一块小正方形区域是否有油。若在一块小正方形区域中探测到有油,则标记为’@’,否则标记为’*’。如果两个相邻区域都为1,那么它们同属于一个石油带,一个石油带可能包含很多小正方形区域,而你的任务是要确定在一片长方形地域中有多少个石油带。 所谓相邻,是指两个小正方形区域上下、左右、左上右下或左下右上同为’@’。

Input

输入数据将包含一些长方形地域数据,每个地域数据的第一行有两个正整数m和n,表示该地域为m*n个小正方形所组成,如果m为0,表示所有输入到此结束。否则,后面m(1≤m≤100)行数据,每行有n(1≤n≤100)个字符,每个字符为’@’或’*’,表示有油或无油。每个长方形地域中,’@’的个数不会超过100。

Output

每个长方形地域,输出油带的个数,每个油带值占独立的一行。油带值不会超过100。

(阅读全文…)

[ACM_ZJUT_1089]Ugly Numbers

杰拉斯 杰拉斯 | 时间:2012-03-28, Wed | 9,006 views
编程算法 

Ugly Numbers

Time Limit:1000MS  Memory Limit:32768K

Description

Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. By convention, 1 is included. Write a program to find and print the n’th ugly number.

Input

Every integer number (≤1500)describing position of ugly number from 1.If integer number is 0,the process should ended. Maybe there are 10000 integer numbers on input data.

Output

Every integer given should output a line as shown below, The <n>th ugly number is <number>. with <n> replaced by the integer number and <number> replaced by the number computed.

(阅读全文…)

[ACM学习心得]关于sync_with_stdio(false);

杰拉斯 杰拉斯 | 时间:2012-03-27, Tue | 23,480 views
编程算法 

在网上查看别人的ACM代码时,发现别人输入输出语句用的总是scanf与printf,有点不解,还以为他们用的都是C语言,而非C++,但今天做的一道题(Sort):

发现与网上的其他高手使用完全相同的方法,使用scanf及printf的代码提交后Accepted,而使用cin及cout的却Time Limit Exceeded

(阅读全文…)

[整理]ACM详解(9)——其他

杰拉斯 杰拉斯 | 时间:2012-02-17, Fri | 5,613 views
编程算法 
有时候会考一些锻炼基本能力的题目,下面使用几个例子进行简单分析。
1IP Address
Description
Suppose you are reading byte streams from any device, representing IP addresses. Your task is to convert a 32 characters long sequence of '1s' and '0s' (bits) to a dotted decimal format. A dotted decimal format for an IP address is form by grouping 8 bits at a time and converting the binary representation to decimal representation. Any 8 bits is a valid part of an IP address. To convert binary numbers to decimal numbers remember that both are positional numerical systems, where the first 8 positions of the binary systems are:
27 26 25 24 23 22 21 20
128  64 32 16 8   4   2   1
Input
The input will have a number N (1<=N<=9) in its first line representing the number of streams to convert. N lines will follow.
Output
The output must have N lines with a doted decimal IP address. A dotted decimal IP address is formed by grouping 8 bit at the time and converting the binary representation to decimal representation.

(阅读全文…)