08 2013 档案
摘要:1166. Computer TransformatConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionA sequence consisting of one digit, the number 1 is initially written into a computer. At each successive time step, the computer simultaneously tranforms each digit 0 into the sequence 1 0 and each digit 1 into t
阅读全文
摘要:【Python】 sorted函数我们需要对List、Dict进行排序,Python提供了两个方法对给定的List L进行排序,方法1.用List的成员函数sort进行排序,在本地进行排序,不返回副本方法2.用built-in函数sorted进行排序(从2.4开始),返回副本,原始输入不变--------------------------------sorted--------------------------------------->>> help(sorted)Help on built-in function sorted in module __builtin_
阅读全文
摘要:1564. HOUSINGConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionFor the Youth Olympic Games in Singapore, the administration is considering to house each team in several units with at least 5 people per unit. A team can have from 5 to 100 members, depending on the sport they do. For exampl
阅读全文
摘要:1049. MondriaanConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionSquares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One day, while working on his latest project, he was intrigued by the number of different ways in which he could order several objects to fill an arb
阅读全文
摘要:1090. HighwaysConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionThe island nation of Flatopia is perfectly flat. Unfortunately, Flatopia has no public highways. So the traffic is difficult in Flatopia. The Flatopian government is aware of this problem. They're planning to build some h
阅读全文
摘要:1036. Crypto ColumnsConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionThe columnar encryption scheme scrambles the letters in a message (or plaintext) using a keyword as illustrated in the following example: Suppose BATBOY is the keyword and our message is MEET ME BY THE OLD OAK TREE. Sin
阅读全文
摘要:1046. Plane SpottingConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionCraig is fond of planes. Making photographs of planes forms a major part of his daily life. Since he tries to stimulate his social life, and since it’s quite a drive from his home to the airport, Craig tries to be very
阅读全文
摘要:题目不算很难,dp的转移方程也很容易列出:设dp[i][j] 代表第i次传球之后球回到j手中的传球数。易得:dp[i][j] = dp[i-1][j-1] + dp[i-1][j-1] 再处理一下头头尾尾即可。 1 #include 2 #include 3 using namespace std; 4 int dp[32][32]; 5 int main() 6 { 7 int n,m; 8 while(cin >> n >> m) 9 {10 memset(dp,0,sizeof(dp));11 int i,j;12 ...
阅读全文
摘要:这道题目想了一会儿觉得不知道如何下手,上网看了下资料,原来这道是一道非常经典的题目。设 f [ k ][ i ][ j ] 表示第 k 步,第 1 条路径走到第 i 行,第 2 条路径走到第 j 行的最大权值和。 状态转移方程: f [ k ][ i ][ j ] = max { f [ k - 1 ][ i - 1 ][ j ], f [ k - 1 ][ i ][ j - 1 ], f [ k - 1 ][ i ][ j ], f [ k - 1 ][ i - 1 ][ j - 1 ] } + map[ i ][ k - i ] + map[ j ][ k - j ] ( 2 #inclu
阅读全文
摘要:1762. 排座椅ConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescription上课的时候总有一些同学和前后左右的人交头接耳,这是令小学班主任十分头疼的一件事情。不过,班主任小雪发现了一些有趣的现象,当同学们的座次确定下来之后,只有有限的D对同学上课时会交头接耳。同学们在教室中坐成了M行N列,坐在第i行第j列的同学的位置是(i,j),为了方便同学们进出,在教室中设置了K条横向的通道,L条纵向的通道。于是,聪明的小雪想到了一个办法,或许可以减少上课时学生交头接耳的问题:她打算重新摆放桌椅,改变同学们桌椅间通道的位置,因为如果一条通道隔开
阅读全文
摘要:2013. Pay BackConstraintsTime Limit: 1 secs, Memory Limit: 256 MBDescription"Never a borrower nor a lender be." O how Bessie wishes she had taken that advice! She has borrowed from or lent money to each of N (1 ≤ N ≤ 100,000) friends, conveniently labeled 1..N.Payback day has finally come.
阅读全文
摘要:给出四个数字,要求,在其间添加运算符和括号,使得计算结果等于24。括号的放置即为决定哪几个数先进行计算。所以,我们先确定首先进行计算的两个相邻的数,计算完成后,就相当于剩下三个数字,仍需要在它们之间添加符号;然后再决定在这三个数中哪两个相邻的数先计算。由此,我们就成功解决了数字的运算次序问题,此时不需要再考虑不同运算符号的优先级问题,因为括号的优先级高于加减乘除。通过循环,我们可以得到第一第二第三次计算的运算符,再通过计算,就可以得出和,若和等于24,即为所求解。在输出格式中,由于括号的放置共六种情况,故根据计算先后顺序的不同,输出时在不同地方放置括号;以下是java源码:import jav
阅读全文
摘要:DescriptionThere are n children in a country marked by integers from 1 to n.They often fight with each other. For each pair of child A and child B, either A beats B or B beats A. It is not possible that both A beats B and B beats A. Of course, one never fight with himself.Child A is not afraid of ch
阅读全文
摘要:DescriptionOn one of my many interplanetary travels I landed on a beautiful little planet called Crucible. It was inhabited by an extremely peace-loving people who called themselves Snooks. They received me very gracefully and told me I had arrived at precisely the right time, as the biggest event o
阅读全文
摘要:最长递增子序列(LIS)本博文转自作者:Yx.Ac 文章来源:勇幸|Thinking(http://www.ahathinking.com)---最长递增子序列又叫做最长上升子序列;子序列,正如LCS一样,元素不一定要求连续。本节讨论实现三种常见方法,主要是练手。题:求一个一维数组arr[i]中的最长递增子序列的长度,如在序列1,-1,2,-3,4,-5,6,-7中,最长递增子序列长度为4,可以是1,2,4,6,也可以是-1,2,4,6。方法一:DP像LCS一样,从后向前分析,很容易想到,第i个元素之前的最长递增子序列的长度要么是1(单独成一个序列),要么就是第i-1个元素之前的最长递增子序列
阅读全文
摘要:今天学习到TreeSet,但是它是按照key的值来排序的,那如果我们想要按照value的值排序呢?这个问题我上网看了好久,终于找到一个比较易懂的例子:例:(统计输入数字的个数)话不多说,看代码就懂import java.util.*;import java.util.Scanner;public class CountNum { public static void main(String[] args){ HashMap hashMap = new HashMap(); Scanner input = new Scanner(System.in); int num = input.n...
阅读全文
摘要:1022. Poor contestant ProbConstraintsTime Limit: 1 secs, Memory Limit: 32 MBDescriptionAs everybody known, “BG meeting” is very very popular in the ACM training team of ZSU.After each online contest, they will go out for “smoking”. Who will be the poor ones that have to BG the others? Of course, the
阅读全文