递推+容斥原理这个题做的晕的不行,实在是糟,等回头什么时候在做一次吧。。。 1 #include 2 #include 3 using namespace std; 4 int c[5],d[5]; 5 long long f[100005]; 6 int main() 7 { 8 fo...
分类:
其他好文 时间:
2015-08-03 06:30:50
阅读次数:
138
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 fo...
分类:
其他好文 时间:
2015-08-02 23:08:40
阅读次数:
212
FONTS-CONF(5) FONTS-CONF(5)名称 fonts.conf -- 字体配置文件文件概要 /etc/fo...
分类:
其他好文 时间:
2015-08-02 10:11:52
阅读次数:
328
1)关于with...as用的用法,这个主要是用于替换try...finally; 更多可以参见:理解Python中的with…as…语法示例代码:try: with open("foo.txt", "w+") as fo: fo.write("www.iptython.me")...
分类:
编程语言 时间:
2015-08-01 21:50:18
阅读次数:
175
//#include
#include
#include using namespace std;//string a,b;
char a[10000],b[1000000];
int asize,bsize;
int kmp(){
int *pi = new int [asize];
pi[0] = -1;
fo...
分类:
其他好文 时间:
2015-08-01 19:00:06
阅读次数:
111
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.Fo...
分类:
其他好文 时间:
2015-07-31 18:00:55
阅读次数:
82
Description 我们知道,在编程中,我们时常需要考虑到时间复杂度,特别是对于循环的部分。例如, 如果代码中出现 for(i=1;iusing namespace std;int c[2005][2005];void in(){ int n, m; c[0][0] = 1; fo...
分类:
其他好文 时间:
2015-07-30 21:17:42
阅读次数:
120
题意:将指定的一段位置[m,n]的链表反置,返回链表头。思路:主要麻烦在链表头,如果要从链表头就开始,比较特殊。 目前用DFS实现,先找到m-1的位置,再找到n+1的位置,中间这段就是否要反置的,交给DFS解决,用个计数器来统计已经反置的个数即可。 1 /** 2 * Definition fo.....
分类:
其他好文 时间:
2015-07-29 12:05:09
阅读次数:
85
插入排序 1 public class InsertionSort extends Sort { 2 3 public Comparable[] insertionSort(Comparable[] a) { 4 int N = a.length; 5 fo...
分类:
编程语言 时间:
2015-07-28 23:02:33
阅读次数:
187
Description
我们知道,在编程中,我们时常需要考虑到时间复杂度,特别是对于循环的部分。例如,
如果代码中出现
for(i=1;i
那么做了n次OP运算,如果代码中出现
fori=1;i
for(j=i+1;j
那么做了n*(n-1)/2 次OP 操作。
现在给你已知有m层for循环操作,且每次fo...
分类:
其他好文 时间:
2015-07-28 21:12:51
阅读次数:
111