自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(42)
  • 问答 (2)
  • 收藏
  • 关注

原创 python中的yield使用详解

目录1 生成器2 contextlib中使用3 coroutines中使用1 生成器2 contextlib中使用3 coroutines中使用

2018-12-15 02:17:45 508 1

原创 C++中的inline

在C语言中,宏函数经常被用来优化代码以降低函数调用的开销;而在C++中,通常更建议使用inline关键字而不是宏函数来实现相同的作用。什么是inline functioninline function中文翻译叫内联函数,即使用inline关键字来告诉编译器可以在代码中展开函数实现,编译器会在编译期使用函数定义来替换函数的调用。inline函数的使用方法inline函数的使用方法非常简单,在...

2018-12-14 20:48:44 263

原创 shared_ptr, effective modern c++笔记

shared_ptr很多编程语言都有GC的机制,可以自动管理内存资源,然后GC机制带来的是资源释放的不确定性,c++原始的手工管理内存资源的方式虽然具有释放的确定性,但是人工管理非常容易出错;如何既能自动释放内存又能保证确定性呢,modern c++给出的方案是shared_ptr。从c++11开始引入的shared_ptr,用来表示指针对指向对象的“共享所有权”;一个对象可以被多个sha...

2018-02-12 17:55:30 228

原创 unique_ptr, effective modern c++笔记

为什么要用智能指针呢?因为裸指针存在很多问题,主要是下面这些:难以区分指向的是单个对象还是一个数组;使用完指针之后无法判断是否应该销毁指针,因为无法判断指针是否“拥有”指向的对象;在已经确定需要销毁指针的情况下,也无法确定是用delete关键字删除,还是有其他特殊的销毁机制,例如通过将指针传入某个特定的销毁函数来销毁指针;即便已经确定了销毁指针的方法,由于1的原因,仍然无法确定到底是用del

2016-08-29 22:41:57 561

原创 图像灰度直方图绘制——使用QT实现一个图像处理软件2

本节主要讲一下怎么使用QP

2014-08-11 16:51:36 7113 12

原创 使用QT实现一个图像处理软件1 —— 图片的加载和显示

为了实现图片的加载和显示,本文主要将shiyong

2014-08-10 16:55:49 7805 3

原创 使用Qt实现一个图像处理软件0

为了学习Qt界面编程和图像处理的基础算法,本人使用实现制作了一个简单的图像处理软件,实现了大部分的图像处理的基础算法,在这里放出来与大家交流下,欢迎大家不吝指教。项目源码地址https://github.com/Aaron-Cai/ImageProcessTool.git本文是这个系列的第一篇文章,将首先先介绍一下软件最终的实现效果。软件组合要实现了一下一些基本的图像处理操作,包括:...

2014-08-10 16:35:13 9752 16

原创 Leetcode #7 Reverse Integer

题目原文 Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321题目的意思很简单,把一个整数倒过来。值得注意的有以下几点:注意倒过来之后的溢出问题,溢出的话返回0注意0结尾的数字,翻转之后要把0拿去。提交代码int reverse(int x) {

2015-08-24 16:24:21 333

原创 Leetcode #6 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 P L S

2015-08-24 11:46:44 305

原创 LeetCode#5 Longest Palindromic Substring

题目原文 Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.这道题是字符串处理中非常经典的题目,求

2015-08-09 17:18:42 304

原创 LeetCode #4 Median of Two Sorted Arrays

题目原文 There are two sorted arrays nums1 and nums2 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)).这道题是第一道标为hard的题,要求求出两个

2015-08-09 17:10:20 266

原创 LeetCode #3 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 lengt

2015-08-09 16:59:47 332

原创 LeetCode #2 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 an

2015-08-09 16:28:17 243

原创 LeetCode #1 Two Sum

题目原文提交代码题目原文 Given 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

2015-08-09 16:23:48 325

原创 Common Lisp的配置

前段时间读了《黑客与画家》这本书,里面强烈推荐了lisp,于是产生了学lisp的想法,稍微谷歌了一下lisp,发觉这是一门很有个性的编程语言,年代古老,影响深刻,不过也似乎比我想象得要难学,anyway,千里之行,始于足下,先从配置做起。lisp有很多变种,也叫lisp方言,这里就先从Common Lisp学起,参考的学习资料在这里,ANSI Common Lisp 中文版。Common Lisp的

2015-05-20 23:11:47 650

原创 USACO Section 2.2 Preface Numbering

题目原文Preface NumberingA certain book's prefaces are numbered in upper case Roman numerals. Traditional Roman numeral values use a single letter to represent a certain subset of decimal numbers.

2014-11-06 15:17:20 459

原创 C++中如何给map按值排序

在C++中,map是一种常用并且非常好用的数据结构,map会自动按照

2014-11-05 17:16:30 3920

原创 USACO Section 2.1 Hamming Codes

题目原文Hamming CodesRob KolstadGiven N, B, and D: Find a set of N codewords (1 <= N <= 64), each of length B bits (1 <= B <= 8), such that each of the codewords is at least Hamming distance of D

2014-11-04 13:30:26 482

原创 USACO Section 2.1 Healthy Holsteins

题目原文Healthy HolsteinsBurch & KolstadFarmer John prides himself on having the healthiest dairy cows in the world. He knows the vitamin content for one scoop of each feed type and the minimum da

2014-11-02 21:40:37 778

原创 USACO 2.1 Sorting a Three-Valued Sequence

题目原文Sorting a Three-Valued Sequence IOI'96 - Day 2Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted ha

2014-11-02 16:43:16 507

原创 USACO 2.1 Ordered Fractions

题目原文Ordered FractionsConsider the set of all reduced fractions between 0 and 1 inclusive with denominators less than or equal to N.Here is the set when N = 5:0/1 1/5 1/4 1/3 2/5 1/2 3/5 2/

2014-10-30 17:31:20 559

原创 USACO Section 2.1 The Castle

题目原文:The CastleIOI'94 - Day 1In a stroke of luck almost beyond imagination, Farmer John was sent a ticket to the Irish Sweepstakes (really a lottery) for his birthday. This ticket turned out t

2014-10-30 17:07:34 408

原创 USACO Section 1.5 Superprime Rib

题目原文Superprime RibButchering Farmer John's cows always yields the best prime rib. You can tell prime ribs by looking at the digits lovingly stamped across them, one by one, by FJ and the USD

2014-10-24 14:14:38 515

原创 USACO Section 1.5 Prime Palindromes

题目原文Prime PalindromesThe number 151 is a prime palindrome because it is both a prime number and a palindrome (it is the same number when read forward as backward). Write a program that finds

2014-10-24 13:21:03 423

原创 USACO Section 1.5 Number Triangles

题目原文Number TrianglesConsider the number triangle shown below. Write a program that calculates the highest sum of numbers that can be passed on a route that starts at the top and ends somewhe

2014-10-23 16:44:44 504

原创 USACO Section 1.4 Mother's Milk

题目原文Mother's MilkFarmer John has three milking buckets of capacity A, B, and C liters. Each of the numbers A, B, and C is an integer from 1 through 20, inclusive. Initially, buckets A and B ar

2014-10-18 21:43:19 466

原创 USACO Section1.4 Arithmetic Progressions

题目原文Arithmetic ProgressionsAn arithmetic progression is a sequence of the form a, a+b, a+2b, ..., a+nb where n=0,1,2,3,... . For this problem, a is a non-negative integer and b is a positive i

2014-10-17 22:09:39 758

原创 USACO Section 1.3 Wormholes

题目原文WormholesFarmer John's hobby of conducting high-energy physics experiments on weekends has backfired, causing N wormholes (2 <= N <= 12, N even) to materialize on his farm, each located at

2014-10-17 20:27:42 3127 1

原创 USACO Section 1.3 Ski Course Design

题目原文Ski Course DesignFarmer John has N hills on his farm (1 Unfortunately, FJ has just found out about a new tax that will be assessed next year on farms used as ski training camps. Upon car

2014-10-17 15:38:47 1217

原创 USACO Section 1.3 Combination Lock

题目原文Combination LockFarmer John's cows keep escaping from his farm and causing mischief. To try and prevent them from leaving, he purchases a fancy combination lock to keep his cows from openi

2014-10-15 19:00:49 1588 1

原创 USACO Section 1.3 Prime Cryptarithm

题目原文Prime CryptarithmThe following cryptarithm is a multiplication problem that can be solved by substituting digits from a specified set of N digits into the positions marked with *. If the s

2014-10-15 16:34:34 608

原创 USACO Section 1.3 PROB Calf Flac(最长回文子串)

题目原文首先还是贴原文:Calf FlacIt is said that if you give an infinite number of cows an infinite number of heavy-duty laptops (with very large keys), that they will ultimately produce all the world's g

2014-08-10 15:34:06 685

原创 USACO Section 1.3 Barn Repair

本题又是一道需要用到贪心算法求解的题目,题目的原文如下。yu

2014-07-22 14:02:04 481

原创 USACO section1.3 Mixing Milk

section 1.3 讲的是贪心算法(greedy algorithm),贪心算法虽然不一定普遍适用,但d

2014-07-19 22:07:56 547

原创 USACO section1.2 Dual Palindromes

本题与上一题类似,主要涉及到ji'zh

2014-07-16 13:23:19 462

原创 USACO section 1.2 Palindromic Squares

原文Palindromic SquaresRob KolstadPalindromes are numbers that read the same forwards as backwards. The number 12321 is a typical palindrome.Given a number base B (2 <= B <= 20 base 10), pri

2014-07-16 13:15:32 495

原创 USACO Section 1.2 Name That Number

题目原文Name That NumberAmong the large Wisconsin cattle ranchers, it is customary to brand cows with serial numbers to please the Accounting Department. The cow hands don't appreciate the advanta

2014-07-16 13:05:39 436

原创 Section 1.2 Transformations

题目原文TransformationsA square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum tran

2014-07-16 12:29:06 394

原创 Section 1.2 Milking Cows

Section 1.2第一节的阅读材料主要介绍了全局搜索的一些知识,崩

2014-07-16 12:15:14 451

原创 Section 1.1 Broken Necklace

Broken Necklace是section 1.1 里面的最后一题,

2014-07-15 14:42:54 576

空空如也

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

TA关注的人

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