- 博客(47)
- 收藏
- 关注
原创 回文串-动态规划
Description回文串是一个正读和反读都一样的字符串,比如level或者noon等等就是回文串。给你一个长度为n( 3 比如字符串 “Ab3bd”可以转换成(“dAb3bAd” or “Adb3bdA”). 但需要插入最少两个字符Sample Input 5Ab3bdSample Output 2问题分析动态规划求解;设ch[1]..ch[n]表示
2017-03-31 21:20:08 1799 3
原创 A - New Bus Route
DescriptionThere are n cities situated along the main road of Berland. Cities are represented by their coordinates — integer numbers a1, a2, ..., an. All coordinates are pairwise distinct.It i
2017-03-29 21:05:38 645
原创 01:最长上升子序列
总时间限制: 2000ms 内存限制: 65536kB描述一个数的序列bi,当b1 你的任务,就是对于给定的序列,求出最长上升子序列的长度。输入输入的第一行是序列的长度N (1 输出最长上升子序列的长度。样例输入71 7 3 5 9 4 8样例输出4来源翻译自 Northeastern Europe 2002, Far-Eastern
2017-03-28 23:40:55 235
转载 数组的连续最大子段和
转至:博客园-Anker's Blog问题描述:输入是一个大小为n的整型数组,要求输出数组的任何连续子数组中的最大值。例如:输入的数组为array[10] = {31,-41,59,26,-53,58,97,-93,-23,84};输出最大连续子数组和为array[2...6]:187 算法1:对所有满足0算法1的伪代码描述如下:maxsofar = 0for(i=0
2017-03-28 23:04:14 308
原创 O - 螺旋方阵
Descriptionn×n的螺旋方阵当n=5和n=3时分别是如下的形式 请给出一个程序,对于任意的输入n(0<n<11),输出按照上面规律所获得的n×n的螺旋方阵。Input输入第一行为整数m(0<m<10),代表有m组输入; 接下来是m行数据,每行输入一个n(0<n<11)。Output按照输入的次序,依次输出
2017-03-28 20:53:09 393
原创 P - 二分查找
Description给出含有n个数的升序序列,保证序列中的数两两不相等,这n个数编号从1 到n。然后给出q次询问,每次询问给出一个数x,若x存在于此序列中,则输出其编号,否则输出-1。Input单组输入。首先输入一个整数n(1 再接下来的一行包含一个正整数q(1 再接下来的q行,每行包含一个正整数x。Output
2017-03-28 19:50:29 407
原创 L - 马拦过河卒
Description棋盘上A点有一个过河卒,需要走到目标B点。卒行走的规则:可以向下、或者向右。同时在棋盘上C点有一个对方的马,该马所在的点和所有跳跃一步可达的点称为对方马的控制点。因此称之为“马拦过河卒”。棋盘用坐标表示,A点(0,0)、B点(n,m)(n,m为不超过15的整数),同样马的位置坐标是需要给出的。现在要求你计算出卒从A点能够到达B点的路径的条数,假设马的位置是固定不动的,并不
2017-03-27 23:21:26 254
原创 N - 青蛙过河
Description1)一条小溪尺寸不大,青蛙可以从左岸跳到右岸,在左岸有一石柱L,石柱L面积只容得下一只青蛙落脚,同样右岸也有一石柱R,石柱R面积也只容得下一只青蛙落脚。 2)有一队青蛙从小到大编号:1,2,…,n。 3)初始时:青蛙只能趴在左岸的石头 L 上,按编号一个落一个,小的落在大的上面-----不允许大的在小的上面。 4)在小溪中有S个石柱、有y片荷叶。 5)规定:溪中的每个
2017-03-25 18:26:39 394
原创 H - 三国佚事——巴蜀之危
Description话说天下大势,分久必合,合久必分。。。却道那魏蜀吴三国鼎力之时,多少英雄豪杰以热血谱写那千古之绝唱。古人诚不我欺,确是应了那句“一将功成万骨枯”。 是夜,明月高悬。诸葛丞相轻摇羽扇,一脸愁苦。原来是日前蜀国战事吃紧,丞相彻夜未眠,奋笔急书,于每个烽火台写下安排书信。可想,这战事多变,丞相运筹 帷幄,给诸多烽火台定下不同计策,却也实属不易。 谁成想这送信小厮竟
2017-03-25 16:27:53 341
原创 A - Jeff and Digits
DescriptionJeff's got n cards, each card contains either digit 0, or digit 5. Jeff can choose several cards and put them in a line so that he gets some number. What is the largest possible numbe
2017-03-25 15:28:26 235
转载 新手怎样学ACM
作者:艾庆兴链接:https://www.zhihu.com/question/56916024/answer/151930400来源:知乎著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。对于新手来说,最重要的是能有稳定的代码能力和基本的解题能力,也就是说遇到自己做过的,或者是知识点类似的题目,应该能稳定想出做法,并且快速的AC它。那么得从两个方面入手,
2017-03-24 08:23:35 695
原创 A - TL
DescriptionValera wanted to prepare a Codesecrof round. He's already got one problem and he wants to set a time limit (TL) on it.Valera has written n correct solutions. For each correct solution
2017-03-22 21:02:31 196
原创 D - 汉诺塔系列1
Descriptionn个盘子的汉诺塔问题的最少移动次数是2^n-1,即在移动过程中会产生2^n个系列。由于发生错移产生的系列就增加了,这种错误是放错了柱子,并不会把大盘放到小盘上,即各柱子从下往上的大小仍保持如下关系:n=m+p+qa1>a2>...>amb1>b2>...>bpc1>c2>...>cq计算所有会产生的系列总数。Inpu
2017-03-22 20:54:52 338
原创 J - 数学黑洞
Description任意一个4位自然数N(N不能是4个数字一样,如1111、2222、….9999是不可以的,N也不能是6174),将组成自然数N的4个数字重新排列,形成一个最大数和最小数,最大数和最小数相减,其差是还是自然数,将差的各数字再重新排列,又形成一个最大数和最小数,最大数和最小数相减,其差还是自然数。反复进行,直到差是一个神秘数6174(数学黑洞)结束。I
2017-03-22 19:00:46 304
原创 G - Fighting_小银考呀考不过四级
Description四级考试已经过去好几个星期了,但是小银还是对自己的英语水平担心不已。小银打算好好学习英语,争取下次四级考试和小学弟小学妹一起拿下它!四级考试的时候,监考老师会按考号分配固定的座位,但唯一不变的是每两个人之间肯定至少会留下两个空座位,原因相信大家都懂得。那么问题来了,我们现在只关注教室里的一排座位,假设每排有n个座位,小银想知道这一排至少坐一个人的前
2017-03-21 20:05:25 281
原创 《ACM程序设计》书中题目-专题总结
《ACM程序设计》书中题目专题总结通过这个专题的练习,初步掌握了一些C++STL(即C++标准模板库)的用法,stl使用十分方便,可以很大程度的提高代码简洁度和程序效率。这个专题作用是让我了解到STL的一些用法,但对其具体的熟练运用还要在以后慢慢练习,其中的更为强大的功能还须慢慢摸索。通过专题的练习,让我掌握了在C++课堂上不曾了解的编程方法,在本专题的练习中也收获很多,以前对英语题有一定的排
2017-03-21 19:23:16 370
原创 M 数值分解
Description对一个自然数N ( 1 Input输入数据有多组,每组占一行,每行包含一个自然数N(1 Output对每组输入,输出有2行。第一行是N分解出的所有数字,以空格分隔,最后一个数字后也有空格;第二行是N分解出的所有数字的个数、乘积。Sample Input202428Sample Output3 3 3 3 3 3 27 1458
2017-03-20 18:36:38 286
原创 Z-26 Two names' abbreviations
DescriptionWhen a Little White meets another Little White:Little White A: (Surprised) !Little White B: ?Little White A: You Little White know "SHDC"? So unbelievable!Little White B: You are
2017-03-20 00:04:47 330
原创 Y-25 Number of every character
DescriptionThe look and say sequence is defined as follows. Start with any string of digits as the first element in the sequence. Each subsequent element is defined from the previous one by "verball
2017-03-19 23:23:39 241
原创 R-18 Semi-Prime Number
DescriptionPrime Number Definition An integer greater than one is called a prime number if its only positive divisors (factors) are one and itself. For instance, 2, 11, 67, 89 are prime numbers
2017-03-19 19:28:25 480
原创 K-加强斐波那契
Description对于斐波那契数列想必各位已经见过了。这里给出一个加强版。F[i] = i (i F[i] = F[i-1] + F[i-2] + F[i-3](i >= 4);Input多组输入。每组输入一个整数n (1Output每组数据输出一个整数,代表F[n]。Sample Input
2017-03-19 17:31:44 274
原创 V-22 Sort the books
DescriptionJim is fond of reading books, and he has so many books that sometimes it's hard for him to manage them. So he is asking for your help to solve this problem.Only interest in the name,
2017-03-19 17:21:32 544
原创 W-23 Tom's Meadow
DescriptionTom's Meadow Tom has a meadow in his garden. He divides it into N * M squares. Initially all the squares were covered with grass. He mowed down the grass on some of the squares an
2017-03-19 16:23:50 357
原创 I-蟠桃记
Description孙悟空在大闹蟠桃园的时候,第一天吃掉了所有桃子总数一半多一个,第二天又将剩下的桃子吃掉一半多一个,以后每天吃掉前一天剩下的一半多一个,到第n天准备吃的时候只剩下一个桃子。这下可把神仙们心疼坏了,请帮忙计算一下,第一天开始吃的时候一共有多少个桃子?Input输入数据有多组,每组占一行,包含一个正整数n(1≤n≤30),表示只剩下一个桃子的时候
2017-03-19 15:36:15 301
原创 F-计算组合数
Description计算组合数。C(n,m),表示从n个数中选择m个的组合数。计算公式如下:若:m=0,C(n,m)=1否则, 若 n=1,C(n,m)=1 否则,若m=n,C(n,m)=1 否则 C(n,m) = C(n-1,m-1) + C(n-1,m). Inpu
2017-03-19 15:27:08 251
原创 E-养兔子
Description一对成熟的兔子每天能且只能产下一对小兔子,每次都生一公一母,每只小兔子的成熟期是一天。某人领养了一对小兔子,一公一母,请问第N天以后,他将会得到多少对兔子。Input测试数据包括多组,每组一行,为整数n(1≤n≤90)。 输入以0结束。Output对应输出第n天有几对兔子(假设没有兔子死亡现象,而且是一夫一妻
2017-03-19 15:22:49 1192
原创 C-递归的函数
Description给定一个函数 f(a, b, c):如果 a ≤ 0 或 b ≤ 0 或 c ≤ 0 返回值为 1;如果 a > 20 或 b > 20 或 c > 20 返回值为 f(20, 20, 20);如果 a 其它情况返回 f(a−1, b, c) + f(a−1, b−1, c) + f(a−1, b, c−1) − f(a-1, b-1, c-1)。
2017-03-19 15:15:51 279
原创 B-王小二切饼
Description王小二自夸刀工不错,有人放一张大的煎饼在砧板上,问他:“饼不许离开砧板,切n(1Input输入切的刀数n。Output输出为切n刀最多切的饼的块数。Sample Input100Sample Output5051 解题思路:
2017-03-19 15:07:30 1200
原创 A-母牛的故事
Description有一头母牛,它每年年初生一头小母牛。每头小母牛从第四个年头开始,每年年初也生一头小母牛。请编程实现在第n年的时候,共有多少头母牛?Input输入数据由多个测试实例组成,每个测试实例占一行,包括一个整数n(0Output对于每个测试实例,输出在第n年的时候母牛的数量。 每个输出占一行。Sampl
2017-03-19 14:58:03 480
原创 S-19 Message queue
DescriptionMessage queue is the basic fundamental of windows system. For each process, the system maintains a message queue. If something happens to this process, such as mouse click, text change,
2017-03-19 14:48:15 245
原创 Mafia
DescriptionOne day n friends gathered together to play "Mafia". During each round of the game some player must be the supervisor and other n - 1people take part in the game. For each person we k
2017-03-18 16:19:26 223
原创 Cinema Line
DescriptionThe new "Die Hard" movie has just been released! There are n people at the cinema box office standing in a huge line. Each of them has a single 100, 50 or 25 ruble bill. A "Die Hard"
2017-03-18 16:07:13 428
原创 Difference Row
题目:DescriptionYou want to arrange n integers a1, a2, ..., an in some order in a row. Let's define the value of an arrangement as the sum of differences between all pairs of adjacent integers.Mor
2017-03-15 22:58:52 314
原创 That the positive number which is dividable by 3 or 5
题目:DescriptionMike is very lucky, as he has two beautiful numbers, 3 and 5. But he is so greedy that he wants infinite beautiful numbers. So he declares that any positive number which is dividable
2017-03-15 22:43:08 268
原创 ind the integer A such that pow(A,N) is as close as possible to B
DescriptionGiven positive integers B and N, find an integer A such that AN is as close as possible to B. (The result A is an approximation to the Nth root of B.) Note that AN may be less than, equal
2017-03-15 20:51:00 474
原创 The most popular color of balloon
题目:DescriptionContest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is o
2017-03-15 18:23:27 271
原创 The reversed sum of two reversed numbers
题目:DescriptionThe Antique Comedians of Malidinesia prefer comedies to tragedies. Unfortunately, most of the ancient plays are tragedies. Therefore the dramatic advisor of ACM has decided to transf
2017-03-15 12:27:26 221
原创 How many items that are double some other item
题目:DescriptionAs part of an arithmetic competency program, your students will be given randomly generated lists of from 2 to 15 unique positive integers and asked to determine how many items in ea
2017-03-14 23:33:25 387
原创 sum of two 20-based number
题目:Description In the 22nd Century, scientists have discovered intelligent residents live on the Mars. Martians are very fond of mathematics. Every year, they would hold an Arithmetic Contest on
2017-03-14 23:20:29 273
原创 FatMouse language translated to English
FatMouse language translated to English题目DescriptionWe all know that FatMouse doesn't speak English. But now he has to be prepared since our nation will join WTO soon. Thanks to Turing we have c
2017-03-14 22:59:38 419
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人