随笔分类 - Sicily
摘要: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
阅读全文
摘要: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
阅读全文
摘要:题目不算很难,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.
阅读全文
摘要: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
阅读全文
摘要://注意题目上说的:若词频相同,则想输出在表中先出现的那一个。因此要用一个记录容器vector代码:#include <iostream>#include <map>#include <vector>#include <string>using namespace std;int main(){ int num; while(cin >> num && num != 0) { map<string,int> records; map<string,int>::iterator itr; vect
阅读全文