随笔分类 -  ACM之小技巧性题目

有点小意思
摘要:问题描述: 任意给定一个32位无符号整数n,求n的二进制表示中1的个数,比如n = 5(0101)时,返回2,n = 15(1111)时,返回4。 若干解决方案: 普通法: 使用移位操作,判末位是否为1;移位的次数为32。 快速法: 这个方法我最喜欢,也常用。迭代n=n&(n-1),消除最右边的1, 阅读全文
posted @ 2018-01-09 19:02 jiu~ 阅读(2056) 评论(0) 推荐(1) 编辑
摘要:https://leetcode.com/problems/increasing-triplet-subsequence/description/ 题目如下: 题意很明确,在一个序列里确认三元递增子序列的存在性。限制O(n)的时间复杂度和O(1)的空间复杂度。 方法:O(n)的时间复杂度,这往往通过 阅读全文
posted @ 2018-01-01 18:06 jiu~ 阅读(264) 评论(0) 推荐(0) 编辑
摘要:https://leetcode.com/problems/first-missing-positive/#/description Given an unsorted integer array, find the first missing positive integer. For examp 阅读全文
posted @ 2017-06-11 12:38 jiu~ 阅读(265) 评论(0) 推荐(0) 编辑
摘要:http://poj.org/problem?id=1002 487-3279 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 288073 Accepted: 51697 Description Businesses like 阅读全文
posted @ 2017-03-17 22:10 jiu~ 阅读(302) 评论(0) 推荐(0) 编辑
摘要:http://codeforces.com/problemset/problem/688/B B. Lovely Palindromes time limit per test 1 second memory limit per test 256 megabytes Pari has a frien 阅读全文
posted @ 2016-07-05 10:06 jiu~ 阅读(546) 评论(0) 推荐(0) 编辑
摘要:题目:zero puzzlingThere is a matrix with m rows and n columns. An element of the matrix has at most four adjacent elements(up, down, left, right). You c... 阅读全文
posted @ 2015-09-21 16:53 jiu~ 阅读(719) 评论(0) 推荐(0) 编辑
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=37GridlandTime Limit:2 Seconds Memory Limit:65536 KBBackgroundFor years, computer scientist... 阅读全文
posted @ 2015-07-31 16:37 jiu~ 阅读(546) 评论(0) 推荐(0) 编辑
摘要:http://codeforces.com/problemset/problem/499/AA. Watching a movieYou have decided to watch the best moments of some movie. There are two buttons on yo... 阅读全文
posted @ 2015-07-22 22:07 jiu~ 阅读(247) 评论(0) 推荐(0) 编辑
摘要:http://codeforces.com/problemset/problem/451/CA -Predict Outcome of the GameTime Limit:2000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64uSubmitS... 阅读全文
posted @ 2015-04-05 14:53 jiu~ 阅读(269) 评论(0) 推荐(0) 编辑
摘要:http://acm.uestc.edu.cn/#/contest/show/54A - AC Milan VS JuventusTime Limit: 3000/1000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others)Submi... 阅读全文
posted @ 2015-03-30 18:54 jiu~ 阅读(278) 评论(0) 推荐(0) 编辑
摘要:问题描述在横轴上放了n个相邻的矩形,每个矩形的宽度是1,而第i(1 ≤ i ≤ n)个矩形的高度是hi。这n个矩形构成了一个直方图。例如,下图中六个矩形的高度就分别是3, 1, 6, 5, 2, 3。请找出能放在给定直方图里面积最大的矩形,它的边要与坐标轴平行。对于上面给出的例子,最大矩形如下图所示... 阅读全文
posted @ 2015-03-20 00:10 jiu~ 阅读(1179) 评论(2) 推荐(0) 编辑
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1003Max SumTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s... 阅读全文
posted @ 2015-03-17 22:54 jiu~ 阅读(509) 评论(0) 推荐(0) 编辑
摘要:http://acm.nyist.net/JudgeOnline/problem.php?pid=528找球号(三)时间限制:2000ms | 内存限制:3000KB难度:2描述xiaod现在正在某个球场负责网球的管理工作。为了方便管理,他把每个球都编了号,且每个编号的球的总个数都是偶数。有一天,x... 阅读全文
posted @ 2015-02-27 23:57 jiu~ 阅读(202) 评论(0) 推荐(0) 编辑
摘要:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2132The Most Frequent NumberTime Limit:5 Seconds Memory Limit:1024 KBSeven (actually six)... 阅读全文
posted @ 2014-11-24 22:46 jiu~ 阅读(254) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示