
ACM每日水水
looushu
還未可知
展开
-
POJ 求平面点阵中的最大共线点数系列 (POJ 1118 + 2606 + 2780)
三道题用的一个代码,,,水过了。题意都是:给出平面若干个点的坐标,求共线的点的最多的点的数目。即在同一条直线的上的最多的点数目。解题思路是:求出两两坐标的两点间的斜率,然后一次比较斜率,相同的则共线,求出最大的共线数,输出即可。(或者可以用三个点共线的做,其实质依然是靠斜率来判断是否共线)。代码如下(两点斜率):/***** 简单ACM水题 ********//*原创 2013-11-20 14:24:30 · 2962 阅读 · 0 评论 -
LeetCode第六题,ZigZag Conversion
题目:The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA原创 2014-08-06 12:15:24 · 2192 阅读 · 0 评论 -
LeetCode第五题,Longest Palindromic Substring
题目原文:Given a string S, find the longest palindromic substring in S. You may assume that the maximum length ofS is 1000, and there exists one unique longest palindromic substring.题意解析:最长回文子串。就是原创 2014-08-05 14:29:41 · 4843 阅读 · 1 评论 -
LeetCode第四题,Add Two Numbers
题目原文:You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it原创 2014-08-04 21:31:32 · 1547 阅读 · 0 评论 -
LeetCode 第三题,Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.原创 2014-08-03 20:38:44 · 10385 阅读 · 4 评论 -
LeetCode 第二题,Median of Two Sorted Arrays
题目再现There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).题意解析原创 2014-08-02 17:18:04 · 2790 阅读 · 0 评论 -
LeetCode 第一题,Two Sum
题目还原Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up t原创 2014-08-01 01:43:51 · 4506 阅读 · 0 评论 -
基础典型算法研究:合并有序数组
做leetcode第二题的时候,发现合并有序数组是一个很有意思的问题,于是,总结如下,部分内容来源于网络各位大神.第一种方法:合并调用sort.即是将两个数组合并在一个数组里面,然后对合并后的数组调用sort函数即可.class Solution: def getArray(self, A, B) : for item in B :原创 2014-08-02 18:30:02 · 1348 阅读 · 0 评论 -
Codeforces Round #231 (Div. 2)
A. Counting SticksWhen new students come to the Specialized Educational and Scientific Centre (SESC) they need to start many things from the beginning. Sometimes the teachers say (not always u原创 2014-02-21 15:40:15 · 1151 阅读 · 0 评论 -
巴仕博弈(Bash Game)小结
问题描述巴什博奕(Bash Game):只有一堆n个物品,两个人轮流从这堆物品中取物,规定每次至少取一个,最多取m个。最后取光者得胜。分析一堆物品共 n 个,两人轮流从中取物,规定每次至少取一个,最多取m个。最后取光者得胜。设 n=(m+1)q+r ( 0≤r≤m )①若 r=0, 后取者必胜,策略如下:若先取者拿走 k 个,则后取者拿走 m+1-k 个,结果剩原创 2013-11-12 23:52:43 · 3596 阅读 · 0 评论 -
算法入门系列一--DP初步
数字三角形(数塔问题)其实动态规划本身并不是一个特定的算法,是一种用途广泛的问题求解方法,一种思想,一种手段。1.1问题描述与状态定义有一个有非负整数组成的三角形,第一行一个数字,下面各行除了最后一行外,每行的每个数字下面左右各一个数字。如图示:从第一行数字开始,每次只能走左下或右下一格,直到走到最后一行,把沿途的走过的所有数字加起来。如何能使这个和最大原创 2013-10-15 01:08:51 · 3614 阅读 · 2 评论 -
每日ACM小题--POJ1006——中国剩余定理的完美诠释 2013年11月04(附录POJ_1005水题一枚)
在《孙子算经》中有这样一个问题:“今有物不知其数,三三数之剩二(除以3余2),五五数之剩三(除以5余3),七七数之剩二(除以7余2),问物几何?”这个问题称为“孙子问题”,该问题的一般解法国际上称为“中国剩余定理”。具体解法分三步:找出三个数:从3和5的公倍数中找出被7除余1的最小数15,从3和7的公倍数中找出被5除余1 的最小数21,最后从5和7的公倍数中找出除3余1的最小数70。用15原创 2013-11-04 23:46:43 · 1973 阅读 · 0 评论 -
ACM进阶计划
ACM进阶计划ACM队不是为了一场比赛而存在的,为的是队员的整体提高。大学期间,ACM队队员必须要学好的课程有:l C/C++两种语言l 高等数学l 线性代数l 数据结构l 离散数学l 数据库原理l 操作系统原理l 计算机组成原理l 人工智能l 编译原理l 算法设计与分析转载 2013-10-15 22:42:52 · 1834 阅读 · 0 评论 -
每日ACM学习以及小水题 2013年11月3日
说明为了向大神看齐,遂响应号召,每天刷一下POJ上面的水题,每天学习一点ACM,做一点ACM题目。我相信积少成多,更相信,开头是艰难的,但是一旦走进去,就会别有一番感受,速度也会加快吧。so ,today is the first day .题目第一题POJ 1003 (传送门:http://poj.org/problem?id=1003)题目描述:De原创 2013-11-04 00:09:14 · 2547 阅读 · 0 评论 -
每日ACM小练习 2013年11月6日(水题)
FIR NYOJ 7 街区最短路径问题街区最短路径问题时间限制:3000 ms | 内存限制:65535 KB难度:4描述一个街区有很多住户,街区的街道只能为东西、南北两种方向。住户只可以沿着街道行走。各个街道之间的间隔相等。用(x,y)来表示住户坐在的街区。例如(4,20),表示用户在东西方向第4个街道,南北原创 2013-11-06 16:52:54 · 1624 阅读 · 0 评论 -
ACM——Tutor(水题一枚)
题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4493题目如下:Problem DescriptionLilin was a student of Tonghua Normal University. She is studying at University of Chicago now. Besides studying原创 2013-11-03 14:49:22 · 1528 阅读 · 0 评论 -
LeetCode之LCP(Longest Common Prefix)问题
这个也是简单题目,但是关键在于题意的理解。 题目原文就一句话:Write a function to find the longest common prefix string amongst an array of strings. 题意是给一个字符串数组,找出这个字符串数组中所有字符串的最长公共前缀。 注意是限定的前缀,而不是子串。原创 2015-07-17 18:47:01 · 3807 阅读 · 0 评论