自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(134)
  • 收藏
  • 关注

转载 面试题之排序总结

面试题之排序总结 插入排序 分析: 插入排序就是通过数字插入有序数组的方式进行排序的, 代码简单, 且易理解。时间复杂度O(N*N) 代码如下: template <typename T> void InsertSort(vector<T>& array) { for(int i=0; i<array.size(); ++ i) { ...

2017-10-24 20:20:00 154

转载 面试题链表总结

面试题链表总结 链表定义为: struct Node { Node():next(nullptr) {}; Node(int val): value(val), next(nullptr){}; int value; node *next; } 规定错误处理方式: 如果返回值为指针,返回nullptr 如果返回值为数字,返回为 -1 O(1)删除链表中...

2017-10-19 22:16:00 158

转载 微软大楼设计方案(中等)(2017 计蒜之道 初赛 第六场)

题目链接:https://nanti.jisuanke.com/t/15772 如果查两个核心部门的最短距离m,需要一下步骤 首先需要两个核心部门所在大楼之间的最低楼高S是多少 然后在算出两个核心部门所在大楼的最低楼层T是多少 然后就可以分为两种情况来讨论了 1: S > T, 那么m为两个核心部门所在大楼的楼距加上两个核心部门的层距。 2:S <= T, 那么m为两个核心...

2017-06-05 14:39:00 144

转载 1131 - 喵哈哈村的几何大师╰☆莣メ誋こ月(“玲珑杯”线上赛 Round #15 河南专场)...

题目链接:http://ifrog.cc/acm/problem/1131 做这个题的时候真的是。。。 数学忘完了, 失了智; 还是一位学弟的思路。 设置等腰三角形的下边长为1,其他的边都可以根据正余弦公式得出近似精确的长度。然后在根据正余弦公式算出所求角的大小。 代码如下: #include<bits/stdc++.h> using namespace std; doubl...

2017-06-05 14:24:00 119

转载 1129 - 喵哈哈村的战斗魔法师丶坏坏い月(“玲珑杯”线上赛 Round #15 河南专场)...

题目链接:http://ifrog.cc/acm/problem/1129 思路就是用线段树查找最左边第一个大于等于v的数,然后返回线段树下表即可。 代码如下: #include<bits/stdc++.h> using namespace std; struct node { int l, r; long long x, add; }; node tre...

2017-06-05 14:19:00 90

转载 1128 - 咸鱼拷问(“玲珑杯”线上赛 Round #15 河南专场)

题目链接:http://ifrog.cc/acm/problem/1128 思路有两种: 线段树查区间最小值和最大值 RMQ查区间最小值和最大值 线段树代码: #include<bits/stdc++.h> using namespace std; const long long INF = 0x3f3f3f3f; long long n; long long a[10...

2017-06-05 14:14:00 92

转载 1127 咸鱼文章(“玲珑杯”线上赛 Round #15 河南专场)

题目链接:http://ifrog.cc/acm/problem/1127 就是将单词翻转一下, 没什么可写的, 代码如下: #include<bits/stdc++.h> using namespace std; string str; bool judge(char ch) { if(ch >= 'a' && ch <= 'z') ...

2017-06-05 13:38:00 77

转载 1126 - 咸鱼旅行(“玲珑杯”线上赛 Round #15 河南专场)

题目链接:http://ifrog.cc/acm/problem/1126 两种思路: 1.用kruskal求这个图的最小生成树,由于kruskal算法先添加边权小的边,然后添加边权大的边。由这个性质可以知道,每添加完边r,如果s,t由不在一个树上两个点变为在同一个树上的两个点,那么这个边就是s,t路径上的最大值。即为答案。 2.用dijkstra算法求两点间的最短路。更新方式换一下就...

2017-06-05 13:34:00 88

转载 1125 咸鱼商店(“玲珑杯”线上赛 Round #15 河南专场)

题目链接:http://ifrog.cc/acm/problem/1125 思路就是二分最大值然后用O1背包判断就好了 代码如下: #include<bits/stdc++.h> using namespace std; int s[1007], v[1007]; int dp[1000007]; int n, m, k; bool judge(int x) { m...

2017-05-31 16:17:00 92

转载 1124 咸鱼魔法记(“玲珑杯”线上赛 Round #15 河南专场)

题目链接:http://ifrog.cc/acm/problem/1124 这道题两种思路 1.二分答案加O(n)判断 2.直接O(n)尺取法,尺取出最大答案 二分代码: #include<bits/stdc++.h> using namespace std; int arr[1000007]; int n, k; bool judge(int x) { in...

2017-05-31 16:12:00 85

转载 1121 Reverse the lights(“玲珑杯”线上赛 Round #15 河南专场)

题目链接:http://ifrog.cc/acm/problem/1121 这道题的思路就是他总共只有k+1个状态,然后枚举所有状态,满足所有灯亮的条件就更新答案。 代码如下: #include<bits/stdc++.h> using namespace std; int n, k; int a[10007]; int main() { while(scanf(...

2017-05-31 15:30:00 73

转载 LightOJ 1055 - Going Together

You are playing a computer game in which three robots (Aneed, Ben and Cindy) are trapped in a labyrinth. Initially all three are situated in three different locations in the maze. There are three...

2017-05-22 19:56:00 82

转载 Light OJ 1054 - Efficient Pseudo Code

Sometimes it's quite useful to write pseudo codes for problems. Actually you can write the necessary steps to solve a particular problem. In this problem you are given a pseudo code to solve a pr...

2017-05-13 23:55:00 96

转载 LightOJ 1053 - Higher Math

You are building a house. You'd prefer if all the walls have a precise right angle relative to the ground, but you have no device to measure angles. A friend says he has a great idea how you coul...

2017-05-13 16:59:00 116

转载 LightOJ 1052 - String Growth

Zibon just started his courses in Computer science. After having some lectures on programming courses he fell in love with strings. He started to play with strings and experiments on them. One da...

2017-05-13 16:44:00 99

转载 4512 吉哥系列故事——完美队形I(LCIS)

吉哥这几天对队形比较感兴趣。   有一天,有n个人按顺序站在他的面前,他们的身高分别是h11, h22 ... hnn,吉哥希望从中挑出一些人,让这些人形成一个新的队形,新的队形若满足以下三点要求,则称之为完美队形:      1、挑出的人保持他们在原队形的相对顺序不变;   2、左右对称,假设有m个人形成新的队形,则第1个人和第m个人身高相同,第2个人和第m-1个人身高相同,依此类推,...

2017-05-04 21:41:00 71

转载 ZOJ 2432-Greatest Common Increasing Subsequence

You are given two sequences of integer numbers. Write a program to determine their common increasing subsequence of maximal possible length. Sequence S1, S2, ..., SN of length N is called an incr...

2017-05-04 11:46:00 68

转载 病毒 (湖南省第八届大学生计算机程序设计竞赛)

Description 你有一个日志文件,里面记录着各种系统事件的详细信息。自然的,事件的时间戳按照严格递增顺序排列(不会有两个事件在完全相同的时刻发生)。 遗憾的是,你的系统被病毒感染了,日志文件中混入了病毒生成的随机伪事件(但真实事件的相对顺序保持不变)。备份的日志文件也被感染了,但由于病毒采用的随机感染方法,主日志文件和备份日志文件在感染后可能会变得不一样。 给出被感染的主日志和备...

2017-05-02 21:02:00 217

转载 1328 台球碰撞 (湖南省第六届大学生计算机程序设计竞赛)

Description 在平面直角坐标系下,台球桌是一个左下角在(0,0),右上角在(L,W)的矩形。有一个球心在(x,y),半径为R的圆形母球放在台球桌上(整个球都在台球桌内)。受撞击后,球沿极角为a的射线(即:x正半轴逆时针旋转到此射线的角度为a)飞出,每次碰到球桌时均发生完全弹性碰撞(球的速率不变,反射角等于入射角)。 如果球的速率为v,s个时间单位之后球心在什么地方? Inpu...

2017-05-02 12:47:00 122

转载 zzuli 1332 内部收益率 (湖南省第六届大学生计算机程序设计竞赛)

在金融中,我们有时会用内部收益率IRR来评价项目的投资财务效益,它等于使得投资净现值NPV等于0的贴现率。换句话说,给定项目的期数T、初始现金流CF0和项目各期的现金流CF1, CF2, ...,CFT,IRR是下面方程的解: 为了简单起见,本题假定:除了项目启动时有一笔投入(即初始现金流CF0 < 0)之外,其余各期均能赚钱(即对于所有i=1,2,...,T,CFi > ...

2017-05-01 20:02:00 260

转载 ZOJ 3715 Kindergarten Election

题目大意 意思就是这里有n个小朋友要选一个班长。 每一个小朋友都有一票,小朋友因为害羞不会投自己,只会投给他们最好的同学。现在1号小朋友想要当班长,而且是当唯一的班长,这就意味着他的票数必须要大于其他人的所有票。他可以通过买糖果给其他小朋友让他们把票投给他自己。 现在求1号当上班长需要花费的最小糖果数。 这道题目的思路就是枚举他最小的票数s,然后每次贪心找到每种情况的最小花费。 对于每种...

2017-04-29 23:31:00 50

转载 LightOJ 1051 - Good or Bad

A string is called bad if it has 3 vowels in a row, or 5 consonants in a row, or both. A string is called good if it is not bad. You are given a string s, consisting of uppercase letters ('A'-'Z'...

2017-04-29 18:39:00 142

转载 LightOJ 1042 - Secret Origins1050 - Marbles

Your friend Jim has challenged you to a game. He has a bag containing red and blue marbles. There will be an odd number of marbles in the bag, and you go first. On your turn, you reach into the b...

2017-04-21 16:23:00 104

转载 LightOJ 1049 - One Way Roads

Nowadays the one-way traffic is introduced all over the world in order to improve driving safety and reduce traffic jams. The government of Dhaka Division decided to keep up with new trends. Form...

2017-04-19 15:55:00 155

转载 LightOJ 1048 - Conquering Keokradong

This winter we are going on a trip to Bandorban. The main target is to climb up to the top of Keokradong. So, we will use a trail. The trail is a continuous marked footpath that goes from Bandorb...

2017-04-18 22:23:00 72

转载 LeightOJ 1046 - Rider

A rider is a fantasy chess piece that can jump like a knight several times in a single move. A rider that can perform a maximum of K jumps during a single move is denoted as a K-rider. For exampl...

2017-04-18 21:06:00 72

转载 LightOJ 1045 - Digits of Factorial

Factorial of an integer is defined by the following function f(0) = 1 f(n) = f(n - 1) * n, if(n > 0) So, factorial of 5 is 120. But in different bases, the factorial may be different. For exam...

2017-04-17 21:22:00 82

转载 LightOJ 1044 - Palindrome Partitioning

A palindrome partition is the partitioning of a string such that each separate substring is a palindrome. For example, the string "ABACABA" could be partitioned in several different ways, such as...

2017-04-17 20:33:00 73

转载 LeetCode 80. Remove Duplicates from Sorted Array II

Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your function should return length = 5, with the first five ...

2017-04-17 11:40:00 45

转载 LeetCode 79. Word Search

Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertical...

2017-04-16 23:06:00 58

转载 LeetCode 78. Subsets

Given a set of distinct integers, nums, return all possible subsets. Note: The solution set must not contain duplicate subsets. For example, If nums = [1,2,3], a solution is: [ [3], [1], [2...

2017-04-14 21:07:00 60

转载 LeetCode 77. Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4], ]...

2017-04-14 20:57:00 37

转载 LeetCode 76. Minimum Window Substring

Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n). For example, S = "ADOBECODEBANC" T = "ABC" Minimum window is "BANC". N...

2017-04-14 20:41:00 51

转载 LeetCode 74. Search a 2D Matrix

Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right. The first integer of each...

2017-04-14 19:35:00 49

转载 LeetCode 73. Set Matrix Zeroes

Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. 题目大意就是将矩阵中等于0的点所在的行和列中的元素全部置为0; 并且要求不得声明额外的数组空间。 既然不得在额外的数组空间中记录, 那么就在本身的数组中记录。 用两个变量x和y分别标记第一行和第一列是...

2017-04-13 19:36:00 40

转载 LightOJ 1043 - Triangle Partitioning

See the picture below. You are given AB, AC and BC. DE is parallel to BC. You are also given the area ratio between ADE and BDEC. You have to find the value of AD. 水题; 说一下题意 两个相似三角形ADE和ABC,给出AB,...

2017-04-12 21:44:00 97

转载 LightOJ 1042 - Secret Origins

This is the tale of Zephyr, the greatest time traveler the world will never know. Even those who are aware of Zephyr's existence know very little about her. For example, no one has any clue as to...

2017-04-12 21:03:00 95

转载 LeetCode 72. Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.) You have the following 3 operations permitted on a wor...

2017-04-12 20:13:00 54

转载 LeetCode 68. Text Justification

Given an array of words and a length L, format the text such that each line has exactly L characters and is fully (left and right) justified. You should pack your words in a greedy approach; that...

2017-04-12 13:38:00 41

转载 LeetCode 65. Valid Number

Validate if a given string is numeric. Some examples: "0" => true " 0.1 " => true "abc" => false "1 a" => false "2e10" => true Note: It is intended for the problem statement to be ...

2017-04-11 20:42:00 41

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除