随笔分类 -  sicily

摘要:Description有三根杆子A,B,C。A杆上有n个(n>1)穿孔圆盘,盘的尺寸由下到上依次变小。要求按下列规则将所有圆盘移至C杆:1.每次只能移动一个圆盘;2.大盘不能叠在小盘上面。可将圆盘临时置于B杆,也可将从A杆移出的圆盘重新移回A杆,其间也可借助C杆,但都必须遵循上述两条规则。传说印度某间寺院也有这样三根柱子,上串64个金盘。寺院里的僧侣依照一个古老的预言,以上述规则移动这些盘子;预言说当这些盘子移动完毕,世界就会灭亡。这个传说叫做梵天寺之塔问题(Tower of Brahma puzzle)。可以证明,当盘子的个数为n时,移动的次数最少为2^n – 1,现给出n,并对盘子从 阅读全文
posted @ 2013-01-19 15:48 Joyee 阅读(261) 评论(0) 推荐(0)
摘要:Description图行变换是计算机图行 学中经常遇到的问题,在计算机中,一个图像通过一些点和它们之间的关系来表示。在这里为了简化问题,我们仅考虑二维图像中的三角形,且只考虑两种变换—— 旋转变换和平移变换。给出一个三角形三个点的坐标和它绕原点逆时针旋转的角度,以及沿x和y方向上平移的距离,求最后三角形各点的坐标。Input输入包括多组测试用例,第一行为一个数T,表示测试用例的个数。对于每组测试用例包括四行,第一行为三个整数r, h, k,分别表示三角形绕原点逆时针旋转的角度,沿x轴移动的距离,沿y轴移动的距离。接下来三行,每行两个数,分别表示三角形的三个点A、B、C的x, y坐标(保证输入 阅读全文
posted @ 2013-01-19 15:43 Joyee 阅读(301) 评论(0) 推荐(0)
摘要:Description编写一个程序,把一个非负的十进制数转换为任意base(2<=base<=16)进制的数。Input输入包括多组测试用例,通过EOF结束。每组测试用例包含两个数,以空格隔开,第一个为需要转换的十进制数,第二个为转换的进制。Output每组测试用例输出一行,为转换后的数的表示,如果转换后的数的某个数位上的数大于等于10,则分别用A, B, C……来表示。考完机试做了下法师班上的题,发现比我们的作业实用+科学很多啊,囧……一直想写一个这个不过各种拖,期末考也有一题类似的,不过不超过10进制。用了白书上的方法,使用字符串常量来简化输出。 1 #include<s 阅读全文
posted @ 2013-01-19 14:35 Joyee 阅读(228) 评论(0) 推荐(0)
摘要:DescriptionMo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is "There' 阅读全文
posted @ 2012-12-16 19:53 Joyee 阅读(1265) 评论(0) 推荐(0)
摘要:模拟赛第二题,难度应该是倒数第三……看样例输入很晕,其实看懂了还是挺简单的,因为没有跨0点的驾驶记录要设计能PASS的测试用例的话会很痛苦……=。=DescriptionLearner drivers need to complete 50 hours of supervised driving with at least 10 hours, or more, of night driving included in the total amount. Each learner must keep a log book of their supervised driving experienc 阅读全文
posted @ 2012-12-11 21:54 Joyee 阅读(325) 评论(0) 推荐(0)
摘要:模拟赛最后一题,看懂了也是挺水的,难度算倒数第二了吧……DescriptionThe National Supermarket Chain (NSC) likes to boast that it has the lowest price for mortadella in the country. In fact, if a customer manages to find cheaper mortadella in any other chain, the NSC will match the price for that customer.Matej and Filip decided 阅读全文
posted @ 2012-12-11 21:49 Joyee 阅读(270) 评论(0) 推荐(0)
摘要:模拟赛第一题,捡分题……DescriptionIn the olden days making decisions was easy. One would get a daisy and start to pluck its petals alternating between Do-it and Do-it-Not until the last petal was reached and a decision was made.Gadget-man wants to use a computerised version. The idea is to work with a random s 阅读全文
posted @ 2012-12-11 21:47 Joyee 阅读(358) 评论(0) 推荐(0)
摘要:1003. tmp DescriptionImplement the following function, which copy string from b to avoid my_strcpy(char* a, char* b)InputnoneOutputnoneHint#include <string.h>#include <stdio.h>int main(){ char str_a[100] = "123456"; char str_b[100] = "123456"; my_strcpy(str_a + 1, str 阅读全文
posted @ 2012-12-11 21:32 Joyee 阅读(242) 评论(0) 推荐(0)
摘要:Description你有一些小球,从左到右依次编号为1,2,3,...,n. 你可以执行两种指令(1或者2)。其中, 1 X Y表示把小球X移动到小球Y的左边, 2 X Y表示把小球X移动到小球Y右边。 指令保证合法,即X不等于Y。 例如,初始状态1,2,3,4,5,6的小球执行1 1 4后,小球... 阅读全文
posted @ 2012-12-11 21:20 Joyee 阅读(1699) 评论(0) 推荐(0)
摘要:DescriptionThe program must switch the text lines in a backward order and split them by the middle, processing the input lines in pairs. If an empty or blank line is found, it is considered as a line but it is not printed out to the output.InputThe input will be a text file with text lines.OutputSta 阅读全文
posted @ 2012-12-11 21:12 Joyee 阅读(521) 评论(0) 推荐(0)
摘要:DescriptionN couples are standing in a circle, numbered consecutively clockwise from 1 to 2N. Husband and wife do not always stand together. We remove the couples who stand together until the circle is empty or we can't remove a couple any more. Can we remove all the couples out of the circle? I 阅读全文
posted @ 2012-12-11 21:04 Joyee 阅读(938) 评论(1) 推荐(0)
摘要:DescriptionGiven a two-dimention array whose elements are all integers,please calculate the sum of its elements,ignoring thoes who sit at the edge of the array.For example,given a 7 * 4 array,you should calculate the sum of the 5 * 2 elements.InputInput contains many test cases.For each case,the fir 阅读全文
posted @ 2012-12-11 20:58 Joyee 阅读(206) 评论(0) 推荐(0)
摘要:Description将输入的一串数中的负数延迟输出,从而分离非负数和负数 例如输入的数是: P1 N1 P2 N2 那么你处理完之后的输出应该是: P1 P2 N1 N2 注意: 非负数之间的输出顺序和输入顺序相同,负数之间的输出顺序和输入顺序也是要求相同的。Input输入有多个case: 每个case的输入有1行。每一行的第一个整数是N,代表这个输入有N个数需要处理,接下来有N个整数。Output对于每个case输出一行,这1行包括N个整数,整数之间以空格隔开。 输入以EOF结束 其实是从实验手册上改过来的题目,原题是奇数偶数分开输出,TA改成了非负数和负数分开输出,但是没改名字……于是名 阅读全文
posted @ 2012-12-11 20:54 Joyee 阅读(264) 评论(0) 推荐(0)
摘要:Description明明想在学校中请一些同学一起做一项问卷调查,为了实验的客观性,他先用计算机生成了N个1到1000之间的随机整数(N≤100),对于其中重复的数字,只保留一个,把其余相同的数去掉,不同的数对应着不同的学生的学号。然后再把这些数从小到大排序,按照排好的顺序去找同学做调查。请你协助明明完成“去重”与“排序”的工作。Input输入包含多个测试数据。每个测试数据有2行,第1行为1个正整数,表示所生成的随机数的个数N,第2行有N个用空格隔开的正整数,为所产生的随机数。Output对每个测试数据输出2行。第1行为1个正整数M,表示不相同的随机数的个数。第2行为M个用空格隔开的正整数,为 阅读全文
posted @ 2012-12-11 20:46 Joyee 阅读(666) 评论(0) 推荐(0)
摘要:DescriptionFor a positive integer N , the digit-sum of N is defined as the sum of N itself and its digits. When M is the digitsum of N , we call N a generator of M .For example, the digit-sum of 245 is 256 (= 245 + 2 + 4 + 5). Therefore, 245 is a generator of 256.Not surprisingly, some numbers do no 阅读全文
posted @ 2012-12-02 19:25 Joyee 阅读(457) 评论(0) 推荐(0)
摘要:DescriptionYou know sorting is very important. And this easy problem is:Given you an array with N non-negative integers which are smaller than 10,000,000, you have to sort this array. Sorting means that integer with smaller value presents first.InputThe first line of the input is a positive integer 阅读全文
posted @ 2012-12-02 17:25 Joyee 阅读(351) 评论(0) 推荐(0)
摘要:DescriptionThere is an objective test result such as ``OOXXOXXOOO". An `O' means a correct answer of a problem and an `X' means a wrong answer. The score of each problem of this test is calculated by itself and its just previous consecutive `O's only when the answer is correct. For 阅读全文
posted @ 2012-12-02 17:02 Joyee 阅读(430) 评论(0) 推荐(0)
摘要:DescriptionHave you passed the problem 1000(A - B)? Yeah,it's very easy!Now,given two integers N and M(0 < N,M <= 1050 ,N > M),calculate N + M and N * M. I think it's also very easy for you!InputThere are several test cases, one line for each case. For each line, there are only two 阅读全文
posted @ 2012-12-01 22:19 Joyee 阅读(259) 评论(0) 推荐(0)
摘要:Description对于5行,5列的矩阵,问这25个整数中:1, 最大,最小的数第i行, 第j列的数2, 对这25个数进行排序,使得从左到右,从上到下非递减,(即:A[0][0] <= A[0][1] <= ... <= A[0][4] <= A[1][0] <= ...,A[4][4])正如你所见,矩阵的下标从0开始计数。Input每组数据包含5行,5列25个整数,输入有多组,EOF为结束标志Output对于每组数据,输出下列格式的信息:MAX: <i, j>MIN: <i, j>array after sorting:a[0][0] 阅读全文
posted @ 2012-12-01 22:13 Joyee 阅读(376) 评论(0) 推荐(0)
摘要:Description输入一个字符串,统计此字符串中字母(a-z, A-Z)、数字(0-9)、空格(' '),和其它字符的个数,输出四类字符的个数。字符串以回车来结束输入,回车不纳入统计,要求能处理空串。Input输入包含多个测试用例,第一行为一个正整数t,表示测试用例的个数,以下的t行,每行输入一个字符串(长度不超过500),每行以回车结束。Output对于每个测试用例,第一行输出Letter及其个数,第二行输出Number及其个数,第三行输出Space及其个数,第四行输出Other及其个数,使用空格分开。注意:两个测试用例之间用一个空行分开。用ASCII码的特点做,注意A~ 阅读全文
posted @ 2012-12-01 22:11 Joyee 阅读(266) 评论(0) 推荐(0)