博文

Another Eight Puzzle(2008-10-08 21:39:00)

摘要:Another Eight Puzzle Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 12   Accepted Submission(s) : 4 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description Fill the following 8 circles with digits 1~8,with each number exactly once . Conntcted circles cannot be filled with two consecutive numbers.There are 17 pairs of connected cicles:A-B , A-C, A-DB-C, B-E, B-FC-D, C-E, C-F, C-GD-F, D-GE-F, E-HF-G, F-HG-H Filling G with 1 and D with 2 (or G with 2 and D with 1) is illegal since G and D are connected and 1 and 2 are consecutive .However ,filling A with 8 and B with 1 is legal since 8 and 1 are not consecutive .In this problems,some circles are already filled,your tast is to fill the remaining circles to obtain a solution (if possivle). Input The first line contains a single integer T(1≤T≤10),the number of test cases. Each test case is a single line containing 8 integers 0......

阅读全文(2633) | 评论:1

decimal system(2008-10-07 15:14:00)

摘要:decimal system Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 28   Accepted Submission(s) : 13 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description As we know , we always use the decimal system in our common life, even using the computer. If we want to calculate the value that 3 plus 9, we just import 3 and 9.after calculation of computer, we will get the result of 12.But after learning <<The Principle Of Computer>>,we know that the computer will do the calculation as the following steps:1 computer change the 3 into binary formality like 11;2 computer change the 9 into binary formality like 1001;3 computer plus the two number and get the result 1100;4 computer change the result into decimal formality like 12;5 computer export the result;In the computer system there are other formalities to deal with the number such as hexadecimal. Now I will give several numb......

阅读全文(2564) | 评论:1

Public Sale(2008-10-07 15:10:00)

摘要:Public Sale Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 19   Accepted Submission(s) : 5 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 虽然不想,但是现实总归是现实,Lele始终没有逃过退学的命运,因为他没有拿到奖学金。现在等待他的,就是像FarmJohn一样的农田生涯。要种田得有田才行,Lele听说街上正在举行一场别开生面的拍卖会,拍卖的物品正好就是一块20亩的田地。于是,Lele带上他的全部积蓄,冲往拍卖会。后来发现,整个拍卖会只有Lele和他的死对头Yueyue。通过打听,Lele知道这场拍卖的规则是这样的:刚开始底价为0,两个人轮流开始加价,不过每次加价的幅度要在1~N之间,当价格大于或等于田地的成本价 M 时,主办方就把这块田地卖给这次叫价的人。Lele和Yueyue虽然考试不行,但是对拍卖却十分精通,而且他们两个人都十分想得到这块田地。所以他们每次都是选对自己最有利的方式进行加价。由于Lele字典序比Yueyue靠前,所以每次都是由Lele先开始加价,请问,第一次加价的时候,Lele要出多少才能保证自己买得到这块地呢? Input 本题目包含多组测试,请处理到文件结束(EOF)。每组测试占一行。每组测试包含两个整数M和N(含义见题目描述,0<N,M<1100) Output 对于每组数据,在一行里按递增的顺序输出Lele第一次可以加的价。两个数据之间用空格隔开。如果Lele在第一次无论如何出价都无法买到这块土地,就输出"none"。 Sample Input 4 2 3 2 3 5 Sample Output 1 none 3 4 5 Author Linle Source ACM程序设计期末考试——2008-01-02(3 教417)     算是比较简单的博议了! 办法比较死!倒着推的! ......

阅读全文(1205) | 评论:0

Worm(2008-10-07 15:06:00)

摘要:Worm Time Limit : 1000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 17   Accepted Submission(s) : 5 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 自从见识了平安夜苹果的涨价后,Lele就在他家门口水平种了一排苹果树,共有N棵。突然Lele发现在左起第P棵树上(从1开始计数)有一条毛毛虫。为了看到毛毛虫变蝴蝶的过程,Lele在苹果树旁观察了很久。虽然没有看到蝴蝶,但Lele发现了一个规律:每过1分钟,毛毛虫会随机从一棵树爬到相邻的一棵树上。比如刚开始毛毛虫在第2棵树上,过1分钟后,毛毛虫可能会在第1棵树上或者第3棵树上。如果刚开始时毛毛虫在第1棵树上,过1分钟以后,毛毛虫一定会在第2棵树上。现在告诉你苹果树的数目N,以及毛毛刚开始所在的位置P,请问,在M分钟后,毛毛虫到达第T棵树,一共有多少种行走方案数。 Input 本题目包含多组测试,请处理到文件结束(EOF)。每组测试占一行,包括四个正整数N,P,M,T(含义见题目描述,0<N,P,M,T<100) Output 对于每组数据,在一行里输出一共的方案数。题目数据保证答案小于10^9 Sample Input 3 2 4 2 3 2 3 2 Sample Output 4 0 [Hint] 第一组测试中有以下四种走法: 2->1->2->1->2 2->1->2->3->2 2->3->2->1->2 2->3->2->3->2[/Hint] Author Linle Source ACM程序设计期末考试——2008-01-02(3 教417)     #include<stdio.h>__int64 a[110][100];int main(){ int n,......

阅读全文(1710) | 评论:0

文本压缩问题(2008-09-09 14:17:00)

摘要:#include<iostream>#include<fstream>#include<stdio.h>#include<string>#define MAX 10000using namespace std;ifstream filein("COMPRE5.DAT");ofstream fileout("comper5.out");string s[1000];int s1[1000]; int len,map[10000],fk;string doc;   void del(string a,int n){ string b(a,n,a.length()); doc=b;} void workout(){ int i,j; for(i=1;i<=len;i++)  map[i]=MAX; map[0]=0; j=0; while(doc.length()>0) {  for(i=0;i<fk;i++)  {    int n=s[i].length();   string b(doc,0,n);   if(s[i]==b)   {    if(map[j]+s1[i]<map[j+s[i].length()])     map[j+s[i].length()]=map[j]+s1[i];   }  }   del(doc,1);  j++; }}int main(){ int N,i; string temp; filein>>N; filein>>temp; fk=0; while(N>0) { &nb......

阅读全文(1559) | 评论:0

Employment Planning(hdu1158)(2008-08-18 15:43:00)

摘要:Employment PlanningTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 606    Accepted Submission(s): 184 Problem Description A project manager wants to determine the number of the workers needed in every month. He does know the minimal number of the workers needed in each month. When he hires or fires a worker, there will be some extra cost. Once a worker is hired, he will get the salary even if he is not working. The manager knows the costs of hiring a worker, firing a worker, and the salary of a worker. Then the manager will confront such a problem: how many workers he will hire or fire each month in order to keep the lowest total cost of the project.   Input The input may contain several data sets. Each data set contains three lines. First line contains the months of the project planed to use which is no more than 12. The second line contains the cost of hiring a worker, the amoun......

阅读全文(2649) | 评论:0

Domino Art(2008-08-17 10:12:00)

摘要: Domino Art Time Limit: 10000ms, Special Time Limit:25000ms, Memory Limit:65536KB Total submit users: 4, Accepted users: 2 Problem 11223 : No special judgement Problem description Lawliet is a very intelligent person, he is often seen solving puzzles or painting beautiful landscapes, in his new challenge he is trying to make some art with dominoes, he will draw a figure on a rectangular grid consisting of 1x1 squares by marking some of these squares, after that he will try to cover the marked squares with dominoes. As you probably know dominoes consist of pieces of size 2x1, for simplicity we assume that the dominoes can only be put horizontally or vertically and that you have an unlimited amount of dominoes available. The cover has to be perfect, meaning that the dominoes must cover only the marked positions and the dominoes must cover all of them, also all the dominoes must lie strictly inside the rectangular grid. Below are shown two examples of possible......

阅读全文(1681) | 评论:0

Sudoku Killer(HDU1426)(2008-08-15 13:09:00)

摘要:  Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 283    Accepted Submission(s): 76 Problem Description 自从2006年3月10日至11日的首届数独世界锦标赛以后,数独这项游戏越来越受到人们的喜爱和重视。据说,在2008北京奥运会上,会将数独列为一个单独的项目进行比赛,冠军将有可能获得的一份巨大的奖品———HDU免费七日游外加lcy亲笔签名以及同hdu acm team合影留念的机会。所以全球人民前仆后继,为了奖品日夜训练茶饭不思。当然也包括初学者linle,不过他太笨了又没有多少耐性,只能做做最最基本的数独题,不过他还是想得到那些奖品,你能帮帮他吗?你只要把答案告诉他就可以,不用教他是怎么做的。数独游戏的规则是这样的:在一个9x9的方格中,你需要把数字1-9填写到空格当中,并且使方格的每一行和每一列中都包含1-9这九个数字。同时还要保证,空格中用粗线划分成9个3x3的方格也同时包含1-9这九个数字。比如有这样一个题,大家可以仔细观察一下,在这里面每行、每列,以及每个3x3的方格都包含1-9这九个数字。例题:答案:   Input 本题包含多组测试,每组之间由一个空行隔开。每组测试会给你一个 9*9 的矩阵,同一行相邻的两个元素用一个空格分开。其中1-9代表该位置的已经填好的数,问号(?)表示需要你填的数。   Output 对于每组测试,请输出它的解,同一行相邻的两个数用一个空格分开。两组解之间要一个空行。对于每组测试数据保证它有且只有一个解。   Sample Input 7 1 2 ? 6 ? 3 5 8 ? 6 5 2 ? 7 1 ? 4 ? ? 8 5 1 3 6 7 2 9 2 4 ? 5 6 ? 3 7 5 ? 6 ? ? ? 2 4 1 1 ? 3 7 2 ? 9 ? 5 ? ? 1 9 7 5 4 8 6 6 ? 7 8 3 ? 5 1 9 8 5 9 ? 4 ? ? 2 3 &......

阅读全文(2370) | 评论:0

Oil Deposits(2008-08-13 14:59:00)

摘要:  Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 22   Accepted Submission(s) : 9 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time, and creates a grid that divides the land into numerous square plots. It then analyzes each plot separately, using sensing equipment to determine whether or not the plot contains oil. A plot containing oil is called a pocket. If two pockets are adjacent, then they are part of the same oil deposit. Oil deposits can be quite large and may contain numerous pockets. Your job is to determine how many different oil deposits are contained in a grid. Input The input file contains one or more grids. Each grid begins with a line containing m and n, the number of rows and columns ......

阅读全文(2577) | 评论:0

哈密顿绕行世界问题(2008-08-13 14:56:00)

摘要:  Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other) Total Submission(s) : 8   Accepted Submission(s) : 4 Font: Times New Roman | Verdana | Georgia Font Size: ← → Problem Description 一个规则的实心十二面体,它的 20个顶点标出世界著名的20个城市,你从一个城市出发经过每个城市刚好一次后回到出发的城市。 Input 前20行的第i行有3个数,表示与第i个城市相邻的3个城市.第20行以后每行有1个数m,m<=20,m>=1.m=0退出. Output 输出从第m个城市出发经过每个城市1次又回到m的所有路线,如有多条路线,按字典序输出,每行1条路线.每行首先输出是第几条路线.然后个一个: 后列出经过的城市.参看Sample output Sample Input 2 5 20 1 3 12 2 4 10 3 5 8 1 4 6 5 7 19 6 8 17 4 7 9 8 10 16 3 9 11 10 12 15 2 11 13 12 14 20 13 15 18 11 14 16 9 15 17 7 16 18 14 17 19 6 18 20 1 13 19 5 0 Sample Output 1: 5 1 2 3 4 8 7 17 18 14 15 16 9 10 11 12 13 20 19 6 5 2: 5 1 2 3 4 8 9 10 11 12 13 20 19 18 14 15 16 17 7 6 5 3: 5 1 2 3 10 9 16 17 18 14 15 11 12 13 20 19 6 7 8 4 5 4: 5 1 2 3 10 11 12 13 20 19 6 7 17 18 14 15 16 9 8 4 5 5: 5 1 2 12 11 10 3 4 8 9 16 15 14 13 20 19 18 17 7 6 5 6: 5 ......

阅读全文(1806) | 评论:0