- 博客(151)
- 问答 (1)
- 收藏
- 关注

原创 I am OFShare
#include using namespace std; void Greeting() { cout<<"Hello world! I am OFShare."<<endl; } int main() { Greeting(); return 0; } public class Main {
2017-03-04 22:25:06
376
原创 UVA 1428 - Ping pong(树状数组)
题目大意:一条大街上住着n个乒乓球爱好者,经常比赛切磋技术。每个人都有一个不同的技能值a[i];每场比赛需要3个人:两名选手,一名裁判。他们有个奇怪的约定,裁判必须住在两名选手之间,而裁判的能力值也必须在两名选手之间。问一共能组织多少种比赛。分析:假设a[1]到a[i-1]中小于a[i]的数有p[i],a[i+1]到a[n]中小于a[i]的数有s[i]个;这样当i为
2017-09-08 10:35:13
541
原创 hdu problem1166 (树状数组)
敌兵布阵Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 99247 Accepted Submission(s): 42037Problem DescriptionC国的死对头A国这段时间正在进行军事演
2017-09-08 10:32:03
514
原创 二叉树的遍历(递归)
1058: 二叉树遍历时间限制: 1 Sec 内存限制: 128 MB提交: 18 解决: 8[提交][状态][讨论版]题目描述对于二叉树T,可以有先序遍历、中序遍历和后序遍历三种遍历方式。现在我们要求给出一棵二叉树的先序遍历序列和中序遍历序列,输出它的广度优先遍历序列。 输入第一行为一个整数t(0输出为每个测试用例单独一行输出广度优先遍
2017-09-05 11:53:32
547
原创 硬币问题(经典dp)
Coin ChangeYou are given coins of different denominations and a total amount of money amount. Write a function to compute the fewest number of coins that you need to make up that amount. I
2017-09-01 23:04:02
806
原创 矩形嵌套(经典dp)
矩形嵌套时间限制:3000 ms | 内存限制:65535 KB难度:4描述有n个矩形,每个矩形可以用a,b来描述,表示长和宽。矩形X(a,b)可以嵌套在矩形Y(c,d)中当且仅当a<c,b<d或者b<c,a<d(相当于旋转X90度)。例如(1,5)可以嵌套在(6,2)内,但不能嵌套在(3,4)中。你的任务是选出尽可能多的矩形排成一行,使得除最后一个外,每一个矩
2017-09-01 20:59:49
392
原创 ACM算法-时间复杂度分析(6.相关练习exercise)
练习1:Analysis of Algorithms练习2:Master TheoremMIT’s Video lecture 1 on Introduction to Algorithms.
2017-08-29 11:02:53
694
转载 ACM算法-时间复杂度分析(5.有关时间复杂度递归的分析)
Analysis of Algorithm | Set 4 (Solving Recurrences)In the previous post, we discussed analysis of loops. Many algorithms are recursive in nature. When we analyze them, we get a recurrence rela
2017-08-29 11:00:01
1051
转载 ACM算法-时间复杂度分析(4.有关时间复杂度循环的分析)
Analysis of Algorithms | Set 4 (Analysis of Loops)We have discussed Asymptotic Analysis, Worst, Average and Best Cases and Asymptotic Notations in previous posts. In this post, analysis of
2017-08-29 10:56:57
763
转载 ACM算法-时间复杂度分析(3.渐进符号)
Analysis of Algorithms | Set 3 (Asymptotic Notations)We have discussed Asymptotic Analysis, and Worst, Average and Best Cases of Algorithms. The main idea of asymptotic analysis is to have a
2017-08-29 10:54:06
1273
转载 ACM算法-时间复杂度分析(2.最坏,平均,最好时间复杂度分析)
Analysis of Algorithms | Set 2 (Worst, Average and Best Cases)In the previous post, we discussed how Asymptotic analysis overcomes the problems of naive way of analyzing algorithms. In this po
2017-08-29 10:52:21
1035
转载 ACM算法-时间复杂度分析(1.渐进分析)
写在前面:我看了这几篇文章,对时间复杂度理解更加深刻了。分享给大家。Analysis of Algorithms | Set 1 (Asymptotic Analysis)Why performance analysis?There are many important things that should be taken care of, like us
2017-08-29 10:48:56
946
原创 网易2018校招内推编程题
题目链接地址:https://www.nowcoder.com/test/6291726/summary1.彩色的砖块#include #include using namespace std;set chs;int main(){ char ch; while(cin>>ch) chs.insert(ch); int n=chs.size(); int a
2017-08-13 16:06:32
851
原创 UVa Spreading the Wealth-11300(数学推导+中位数)
Spreading the WealthProblemA Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, everyone has converted all o
2017-06-27 22:37:41
517
原创 UVa Commando War-11729(排序+贪心)
There is a war and it doesn't look very promising for your country. Now it's time to act. You have a commando squad at your disposal and planning an ambush on an important enemy camp located nearby. Y
2017-06-26 23:52:38
443
原创 UVaThe Dragon of Loowater-11292(排序+贪心)
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem. The shores of Rellau Creek in central Loowater had always been a prime breeding ground for geese. Due to t
2017-06-26 21:33:27
329
原创 UVa10976-Fractions Again?!(枚举)
//思路:枚举y:[k+1,2k]#include#includeusing namespace std;int main() { int k; while(scanf("%d", &k) == 1 && k) { vector X, Y; for(int y = k+1; y <= k*2; y++) { // 1/k = 1/x + 1/y =>
2017-06-25 11:43:42
393
原创 UVa 11059(枚举)
Given a sequence of integers S = {S1, S2, . . . , Sn}, you should determine what is the value of themaximum positive product involving consecutive terms of S. If you cannot find a positive sequence,
2017-06-25 11:01:22
311
原创 hdu Problem-1426数独问题(dfs+回溯+枚举)
Sudoku KillerTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 8089 Accepted Submission(s): 2497Problem Description自从2006年3月10日
2017-06-24 15:18:04
471
原创 UVa 725(简单枚举)
Write a program that finds and displays all pairs of 5-digit numbers that between them use the digits 0 through 9 once each, such that the first number divided by the second is equal to an integer N,
2017-06-23 17:20:09
405
原创 UVa 1592Database(map的妙用)
Peter studies the theory of relational databases. Table in the relational database consists of values that are arranged in rows and columns. There are different normal forms that database may adhere
2017-06-21 15:25:01
424
原创 UVa 540(map+queue)
Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, though it occurs often in everyday life. At lunch time the qu
2017-06-20 22:45:49
280
原创 hdu Problem-4277(dfs+set)
USACO ORZTime Limit: 5000/1500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4954 Accepted Submission(s): 1630Problem DescriptionLike everyone, c
2017-06-18 09:27:37
513
原创 hdu Problem-1004(map+sort)
Let the Balloon RiseTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 121221 Accepted Submission(s): 47632Problem DescriptionCo
2017-06-18 00:32:53
335
原创 UVa136 Ugly Numbers(优先队列+set判重)
//思路:如果x是丑数,那么2*x,3*x,5*x都是丑数,则可以用一个优先队列保存生成的丑数(另外需要判重即相同的丑数不能入队列)AC源码:#include #include #include #include using namespace std;const int A[]={2,3,5};typedef long long LL;int main(){
2017-06-17 22:05:09
419
原创 hdu Problem-1896(优先队列+模拟)
StonesTime Limit: 5000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 2739 Accepted Submission(s): 1763Problem DescriptionBecause of the wron
2017-06-17 13:45:22
333
原创 hdu Problem-5703
DesertTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 1126 Accepted Submission(s): 803Problem DescriptionA tourist gets lost
2017-06-17 08:53:49
421
原创 hdu Problem-1678(priority_queue+模拟)
ShopaholicTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3117 Accepted Submission(s): 1706Problem DescriptionLindsay is a sh
2017-06-16 21:38:58
358
原创 priority_queue的用法
class templatestd::priority_queuetemplate , class Compare = less > class priority_queue;Priority queuePriority queues are a type of container adaptors, specifically designed such
2017-06-16 17:25:43
345
原创 sort的用法
std::sortdefault (1)template void sort (RandomAccessIterator first, RandomAccessIterator last);custom (2)template void sort (RandomAccessIterator first, RandomAcce
2017-06-16 17:16:47
362
原创 hdu Problem-5702(结构体排序)
Solving OrderTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1306 Accepted Submission(s): 859Problem DescriptionWelcome to HD
2017-06-16 17:04:48
461
原创 UVa1395(最小值最小生成树+并查集)
//思路:用结构体保存一条边的信息(u,v,w),因为是求最小的生成树,所以把边排序后,从最小的边(起点)依次枚举可以构成的生成树AC源码:#include #include #include #include using namespace std;const int INF=(1<<30);int n,m,MIN_NUM=INF,p[105];int find
2017-06-16 13:20:36
484
原创 CodeM美团点评编程大赛 音乐研究
美团外卖的品牌代言人袋鼠先生最近正在进行音乐研究。他有两段音频,每段音频是一个表示音高的序列。现在袋鼠先生想要在第二段音频中找出与第一段音频最相近的部分。具体地说,就是在第二段音频中找到一个长度和第一段音频相等且是连续的子序列,使得它们的 difference 最小。两段等长音频的 difference 定义为:difference = SUM(a[i] - b[i])2 (1 ≤
2017-06-15 20:55:31
854
原创 UVa101(模拟+基础数据结构vector)
//思路:找到4中命令的基础操作,模拟AC源码:#include #include #include #include using namespace std;#define LOCconst int MAXN=30;int n;vector pile[MAXN];void find_block(int a,int& p,int& h){ for(p=0;
2017-06-15 19:59:35
357
原创 hdu Problem-4004(二分)
The Frog's GamesTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)Total Submission(s): 7263 Accepted Submission(s): 3482Problem DescriptionThe annua
2017-06-15 15:32:25
354
原创 UVa10129(欧拉回路,并查集)
//思路:把单词的第一个字母和最后一个字母当成结点,单词的第一个字母连向最后一个字母看成有向边。每个结点记录度数(出度与入度之和,可以把出度+1,入度-1),用并查集判断图的连通性(可以用cc=26记录,最后统计是不是1)AC源码:#include #include #include using namespace std;const int MAXN=256;
2017-06-15 12:24:05
423
原创 UVa10474(排序和查找)
//思路:用vector存储,在sort排序就可以了AC代码:#include #include #include using namespace std;int main(){ int N,Q,kase=0; while(cin>>N>>Q&&N) { cout<<"CASE# "<<(++kase)<<":"<<endl; vector ivec;
2017-06-13 00:03:18
460
原创 UVa156(map的使用)
//思路:用map记录重排string后出现的次数,如果为1次,就是我们想要的结果AC源码:#include #include #include #include #include #include using namespace std;map cnt;vector svec;void solve(){ string buf; while(cin>>bu
2017-06-11 21:04:22
398
原创 Connected Cells in a Grid(dfs)
Consider a matrix with rows and columns, where each cell contains either a or a and any cell containing a is called a filled cell. Two cells are said to be connected if they are adj
2017-06-10 22:16:51
493
原创 最大化平均值(二分搜索)
//有n个物品的重量和价值分别是Wi和Vi.从中选出k个物品使得单位重量的价值最大bool judge(double mid){ vector vec; for(int i=0;i<N;++i) vec.push_back(v[i]-w[i]*mid); sort(vec.begin(),vec.end()); double sum=0; for(int i=0;i<K;++i)
2017-06-08 18:06:22
414
空空如也
如何安装sql server 2008
2016-03-08
TA创建的收藏夹 TA关注的收藏夹
TA关注的人