- 浏览: 65436 次
- 性别:
最新评论
-
hellobin:
看精妙的算法真的是一种享受
UVA 11205 - The broken pedometer
文章列表
The Problem
A marathon runner uses a pedometer with which he is having problems. In the pedometer the symbols are represented by seven segments (or LEDs):
But the pedometer does not work properly (possibly the sweat affected the batteries) and only some of the LEDs are active. The runner ...
qsort()应用大全
- 博客分类:
- Algorithm
1.qsort函数:
原 型: void qsort(void *base, int nelem, int width, int (*fcmp)(const void *,const void *));
功 能: 使用快速排序例程进行排序
参 数:
1 待排序数组首地址
2 数组中待排序元素数量
3 各元素的占用空间大小
4 指向函数的指针,用于确定排序的顺序
说 明:qsort函数是ANSI C标准中提供的,其声明在stdlib.h文件中,是根据二分法写的,其时间复杂度为n*log(n)。
qsort要求提供的函数是需要自己定义的一个比较函数,比较函数使得qsort通用性更好 ...
UVA 10167 - Birthday Cake
- 博客分类:
- UVA
Background
Lucy and Lily are twins. Today is their birthday. Mother buys a birthday cake for them.Now we put the cake onto a Descartes coordinate. Its center is at (0,0), and the cake's length of radius is 100.
There are 2N (N is a integer, 1<=N<=50) cherries on the cake. Mother wants to c ...
Physics teachers in high school often think that problems given as text are more demanding than pure computations. After all, the pupils have to read and understand the problem first!
So they don't state a problem like ``U=10V, I=5A, P=?" but rather like ``You have an electrical circuit tha ...
大家都知道,递归的本质和栈数据的存取很相似了,都是先进去,但是往往最后处理!再者对于递归函数的局部变量的存储是按照栈的方式去存的,对于每一层的递归函数在栈中都保存了本层函数的局部变量,一边该层递归函数结束时能够保存原来该层的数据!如图:如上图递归式依次往下进行的,并且在该层递归函数还没结束即将进入下一层递归调用时,将会把该层函数中的局部变量保存起来,以供下次使用! 好了,以上是递归函数的数据存储方式,可是有时候我们又得抓头了,递归的话,有时候又很难理解,貌似总也想不通!
于是我又把每一层递归函数化分为三部分了,第一部分:是递归调用前的一些数据处理,判断以及递归结束判断(当然了结束条件肯定在 ...
Eclipse是著名的跨平台的自由集成开发环境(IDE)。6月22日Eclipse 3.7 正式发布,代号是 Indigo 。
在 Windows 7 下初始后化,发现界面变化不大,但中文字体却面目全非,小得根本看不见,而且也看起来很不爽。其实这是 Eclipse 的默认字体换了,以前的一直是 Courier New ,这次eclipse用的字体是 Consolas ,这是一个很好的编程字体了,无奈就是中文默认太小了。
This is a problem you can face while developing applications in Eclipse here is a solution for this problem.And also a bug reported for this problem here Windows Menu –> Preferences –> General (expand it) –> Workspace (click on it). Look for a box “Text File Encoding”. Default will be “Cp125 ...
“Oh God”, Lara Croft exclaims, “it’sone of these dumb riddles again!”
In Tomb Raider XIV, Lara is, as ever, gunning her way through ancient Egyptian pyramids, prehistoric caves and medival hallways. Now she is standing in front of some important Germanic looking doorway and has to solve a lin ...
Given ambyngrid of letters, (), and a list of words, find the location in the grid at which the word can be found. A word matches a straight, uninterrupted line of letters in the grid. A word can match the letters in the grid regardless of case (i.e. upper and lower case letters are to be treated as ...
UVA 401 - Palindromes
- 博客分类:
- UVA
A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string"ABCDEDCBA"is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.
A mirrored string is a str ...
Time Limit:
10000ms
Memory Limit:
65536kB
Description
如果一个正整数n至少在两个不同的进位制b1和b2下都是回文数(2<=b1,b2<=10< span="">),则称n是双基回文数(注意,回文数不能包含前导零)。输入十进制的正整数S<106,输出比S大的最小双基回文数(十进制)
Input
一个十进制整数
Output
一个十进制整数
Sample Input
1600000
Sample Output
1632995
http://nns ...
It is easy to see that for every fraction in the form(k> 0), we can always find two positive integersxandy,x≥y, such that:
.
Now our question is: can you write a program that counts how many such pairs ofxandythere are for any givenk?
Input
Input contains no more than 100 lines, each ...
一个35岁左右的白骨精来找我们,她需要在两个工作里面做选择。一个是年薪30万的制片总监,一个是年薪10万的市场策划。她喜欢后者的节奏与内容,却被前面的工资吸引。我们仔细算了一下她的工作时间:前者是每天加班,节 ...
最大连续子序列和问题是个很老的面试题了,最佳的解法是O(N)复杂度,当然其中的一些小的地方还是有些值得注意的地方的。这里还是总结三种常见的解法,重点关注最后一种O(N)的解法即可。需要注意的是有些题目中的最大连 ...
UVA 725 - Division
- 博客分类:
- UVA
Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits0through9once each, such that the first number divided by the second is equal to an integerN, where. That is,
abcde / fghij =N
where each letter represents a different digit. The first digit ...