自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

D_R的博客

要啥自行车?

  • 博客(23)
  • 收藏
  • 关注

原创 HDU前5题

1000Calculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Output2#include<iostream>using n

2017-03-28 16:57:04 334

原创 字符串的包含

给定一个字符串a和一个字符串b,如何最快判断出短字符a是b的子集//解法1:暴力bool jundge(string &a,string &b){ for (int i = 0;i<a.length();i++) { int j; for (j = 0; (j < a.length())&&a[i]!=b[j];j++)//如果a中的第i个元素在b

2017-03-25 23:09:25 239

原创 字符串的旋转

给定一个字符串abcdef,将前3个移到后面变成defabc.#include <iostream>using namespace std;//解法1:暴力/*void LeftshiftOne(char *s,int n){ char a = s[0]; for (int i = 0; i < n;i++) { s[i] = s[i + 1];

2017-03-25 21:31:23 250

原创 unity给按钮贴图添加图片

1.在Assets\Resources目录新建的两个文件夹subjectbtn、subjectbtn_highlight,subjectbtn用于存放各个科目按钮的默认状态图片,subjectbtn_highlight用于存放各个科目按钮的鼠标滑过或点击时的状态图片。 2.将各个按钮的背景图片复制到以前两个文件夹中,格式为PNG. 3.在unity下点击某个图片,在Inspector中修改Tex

2017-03-18 09:54:24 27513 1

原创 371. Sum of Two Integers

Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example: Given a = 1 and b = 2, return 3.就是不用加号实现加法: 解法1: //就是不ac,为啥,在IDE上运行通过class Solution {public:

2017-03-10 12:06:48 241

原创 111.Minimum Depth of Binary Tree

Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 二叉树的最小深度:解法:class Solution {public:

2017-03-10 10:45:03 358

原创 104. Maximum Depth of Binary Tree

Total Accepted: 219677 Total Submissions: 427419 Difficulty: Easy Contributors: Admin Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path fro

2017-03-10 10:38:25 316

原创 136. Single Number

Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extra me

2017-03-08 11:32:23 310

原创 520. Detect Capital

Given a word, you need to judge whether the usage of capitals in it is right or not.We define the usage of capitals in a word to be right when one of the following cases holds:All letters in this word

2017-03-07 21:02:34 281

原创 292. Nim Game

You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone will be the

2017-03-07 18:57:32 180

原创 485. Max Consecutive Ones

Total Accepted: 23956 Total Submissions: 43582 Difficulty: Easy Contributors: Stomach_ache Given a binary array, find the maximum number of consecutive 1s in this array.Example 1: Input: [1,1,0,1,

2017-03-07 18:42:05 233

原创 C++关联容器(unordered_map,vector,unordered_set)

说明书: http://classfoo.com/ccby/article/qNNOJ#sec_4Gxme0unordered_set:(无序集合)//500class Solution {public: vector<string> findWords(vector<string>& words) { vector<string> res;//来一个string类的

2017-03-06 19:14:27 1613

原创 500. Keyboard Row

Total Accepted: 12327 Total Submissions: 20383 Difficulty: Easy Contributors: Admin Given a List of words, return the words that can be typed using letters of alphabet on only one row’s of American

2017-03-06 18:55:24 218

原创 C++的标准库的各种容器

unordered_set:class Solution {public:    vector findWords(vector& words) {        vector res;        unordered_set row1{'q','w','e','r','t','y','u','i','o','p'};        unordered_set row

2017-03-06 18:47:48 517

转载 c++ 标准库的各种容器(vector,deque,map,set,unordered_map,unordered_set,list)的性能考虑

全部没有整理,(先收集)待理解 一、vectorvector采用一段连续的内存来存储其元素,向vector添加元素的时候,如果容量不足,vector便会重新malloc一段更大的内存,然后把原内存中的数据memcpy到新的内存中,并free原内存块,然后将新元素加入。vector的元素插入性能跟以下几个要素关系重大:1. 插入的位置头部插入:将所有元素后移,然后将新元素插入

2017-03-06 18:34:11 650

原创 463. Island Perimeter

Total Accepted: 27942 Total Submissions: 49580 Difficulty: Easy Contributors: amankaraj You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 represents water.

2017-03-06 18:15:15 208

原创 344. Reverse String

Write a function that takes a string as input and returns the string reversed.Example: Given s = “hello”, return “olleh”.Subscribe to see which companies asked this question.Show Tags Show Similar Pr

2017-03-06 16:29:15 214

原创 496. Next Greater Element I

You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements are subset of nums2. Find all the next greater numbers for nums1’s elements in the corresponding places of nums2.The

2017-03-05 21:21:36 221

原创 412. Fizz Buzz

Write a program that outputs the string representation of numbers from 1 to n.But for multiples of three it should output “Fizz” instead of the number and for the multiples of five output “Buzz”. For n

2017-03-05 19:26:02 285

转载 vector的用法实例解析C++

本文实例展示了C++中的vector用法,分享给大家供大家参考。具体如下:一、概述vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。vector是一个容器,它能够存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,可以动态改变大小。例如:?1234

2017-03-05 18:43:12 4945

原创 Ackerman函数

顺序为n,m时:#include using namespace std;int ack(int n, int m){ if (n == 1 && m == 0) return 2; else if (n == 0 && m >= 0) return 1; else if (n >= 2 && m == 0) return n + 2; else

2017-03-04 19:04:22 526

原创 P1149 火柴棒等式

题目描述给你n根火柴棍,你可以拼出多少个形如“A+B=C”的等式?等式中的A、B、C是用火柴棍拼出的整数(若该数非零,则最高位不能是0)。用火柴棍拼数字0-9的拼法如图所示:注意:加号与等号各自需要两根火柴棍如果A≠B,则A+B=C与B+A=C视为不同的等式(A、B、C>=0)n根火柴棍必须全部用上输入输出格式输入格式:输

2017-03-04 16:36:43 354

原创 P1036 选数

题目描述已知 n 个整数 x1,x2,…,xn,以及一个整数 k(k<n)。从 n 个整数中任选 k 个整数相加,可分别得到一系列的和。例如当 n=4,k=3,4 个整数分别为 3,7,12,19 时,可得全部的组合与它们的和为:3+7+12=223+7+19=297+12+19=383+12+19=34。现在,要求你计算出和为素数共有多少种。

2017-03-04 16:14:17 3058

空空如也

空空如也

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

TA关注的人

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