题目链接:http://acm.uestc.edu.cn/#/problem/show/1091
题目大意:求模式串p,在s中出现的次数,但是p能平移到s即可,比如s: 1 3 4和 p :0 2 3;
题目思路:处理出每一位相对前一位的变化,然后KMP即可;
代码:
//author:ACsorry
//result:Yes
#include
#include
#include
#i...
分类:
其他好文 时间:
2015-05-15 09:06:28
阅读次数:
125
既然已经学习了函数,学习注释是个不错的主意。注释是你留给其他程序员帮助介绍你的代码的笔记。编译器将绝大部分的忽略他们。
你需要注意的是Rust有两种形式的注释:单行注释和文本注释。
// Line comments are anything after ‘//’ and extend to the end of the line.
let x =...
分类:
其他好文 时间:
2015-05-15 09:08:21
阅读次数:
179
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/45739753
Reverse a singly linked list.
click to show more hints.
Hint:
A linked list can be reversed either iteratively or recursively. Could you implement both?
思...
分类:
其他好文 时间:
2015-05-15 09:07:25
阅读次数:
122
描述:
Given two binary strings, return their sum (also a binary string).
For example,
a = "11"
b = "1"
Return "100".
思路:
将字符串从后向前进行相加,最后有进位的话再创造新的位数,最后将字符串反转,输出即可。...
分类:
其他好文 时间:
2015-05-15 09:06:04
阅读次数:
99
Rust语言有一些被认为是原生类型的数据类型。这意味着它们是语言内建的。Rust是这样的一种结构,这种结构是标准库在这些类型上提供了一些有用的类型,但是这些才是最原始的。
Booleans
Rust有一个内置的boolean类型,名为bool。有两个值:true和false:
let x = true;
let y: bool = ...
分类:
其他好文 时间:
2015-05-15 09:06:49
阅读次数:
122
0-1背包问题
问题描述
给定n个物品和一背包。物品i的重量是wi,其价值为vi,背包的容量为W。应如何选择装入背包的物品,使得装入背包中物品的总价值最大?约束条件
放入背包的物品的重量<=背包容量W
物品只能进入背包或不进入背包,不可拆分,区别于部分背包问题。求解目标
我们可以这样来刻画问题的解。
假如有n个物品,用Xi表示第i个物品的状态。Xi 的值为0或1。0表示物品未...
分类:
其他好文 时间:
2015-05-15 09:07:17
阅读次数:
96
1.malloc与free是C++/C语言的标准库函数,new/delete是C++的运算符。它们都可用于申请动态内存和释放内存。
2.对于非内部数据类型的对象而言,光用maloc/free无法满足动态对象的要求。对象在创建的同时要自动执行构造函数,对象在消亡之前要自动执行析构函数。由于malloc/free是库函数而不是运算符,不在编译器控制权限之内,不能够把执行构造函数和析构函数的...
分类:
其他好文 时间:
2015-05-15 09:05:17
阅读次数:
98
题解:
首先我们发现对于每个串,我们把它hash一下,然后建一棵平衡树来支持“插入”、“删除”、“下传标记”这三种操作就可以记录并更新一个点的答案了。
然后每个串的串长都较小,修改字符时可以暴力重新hash。
注意:
一对互相交换字符的字符串要先一起删掉再一起往平衡树里加。
可能是同一个串的俩字符交换,此时不能从平衡树中删两遍。
德莱文初始攻速接斧头之间只能再A一下(雾,呃觉得两条太...
分类:
其他好文 时间:
2015-05-15 09:05:34
阅读次数:
385
描述:
Given two strings s and t, determine if they are isomorphic.
Two strings are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters....
分类:
其他好文 时间:
2015-05-15 09:03:17
阅读次数:
111
细数那些年的优质代码...
分类:
其他好文 时间:
2015-05-15 09:02:46
阅读次数:
147
描述:
A peak element is an element that is greater than its neighbors.
Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.
The array may contain multiple peaks, in that case return the index to any one of the peaks is f...
分类:
其他好文 时间:
2015-05-15 09:03:58
阅读次数:
134
题目大意:
给你面值为1分、2分、5分的硬币,并且这些硬币的数量分别为N1,N2和N5。问:
这些硬币最小不能表示的值为多少。
思路:
母函数问题,通过分析,可得:
g(x) = (1+x+x^2+x^3+…+x^N1) * (1+x^2+x^4+…x^(2*N2) ) * (1+x^5+x^10+…x^(5*N5) )
这些硬币能表示的最大值Max = N1 + N2*2 + N5*5。考虑1,2,…,Max,Max+1次幂的系数是
否为令,找出这些硬币不能表示的最小的值。...
分类:
其他好文 时间:
2015-05-15 09:03:07
阅读次数:
116
描述:
Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all numbers in this range, inclusive.
For example, given the range [5, 7], you should return 4.
思路:
由于相邻的两个数最低位肯定有0有1,所以直接and肯定为0,所以可以通过直接and来和向右移位获得一个区间内的相同的位数,最后再通过向左...
分类:
其他好文 时间:
2015-05-15 09:03:20
阅读次数:
104
题目:Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical...
分类:
其他好文 时间:
2015-05-15 09:01:13
阅读次数:
145
在以前的博文中——CAD批量处理工具——BatchProc,即只要用户输入处理单个文件的代码,即可批量处理多个文件。使用起来特别方便。 在现在的地籍处理中,处理Excel的情况比较多,尤其需要反反复复修改,那些做数据的真是伤不起!他们数据的特点是: (1)在某一个环节上,才发现上一个环节出了问题,得...
分类:
其他好文 时间:
2015-05-15 09:00:13
阅读次数:
211
1,实现RequestAware接口 //模拟对象 User model=new User(); user.setName=“lisi”;2,ValueStack value=(ValueStack) requestMap.get("struts.valueStack");3.value.push....
分类:
其他好文 时间:
2015-05-15 09:00:48
阅读次数:
112
1 #include 2 #include 3 void ojmd(int *a,int *b); 4 5 void ojmd_dg(int *a,int *b); 6 7 int main(void){ 8 int a=12; 9 int b=6;10 ojmd(&a...
分类:
其他好文 时间:
2015-05-15 08:59:59
阅读次数:
107