自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(10)
  • 资源 (1)
  • 收藏
  • 关注

原创 爬楼梯

<br />/* 爬楼梯问题:每次可以跨上1…M个台阶,一共有N个台阶,问从最底下爬到最高处有几种爬法 */ #include <stdio.h> #define MAX 100 /* 共n个台阶,每次最多m个台阶,f[i]保存爬n个台阶的爬法总数,返回f[n] * 优化版O(n) */ long long PaLouTi(const int n, const int m, long long * const f) { int i; f[0] = f[1] = 1; for

2011-03-30 23:08:00 1297

原创 关于爬楼梯问题的解法

/* 爬楼梯问题:每次可以跨上1…M个台阶,一共有N个台阶,问从最底下爬到最高处有几种爬法 */ #include #define MAX 100 /* 共n个台阶,每次最多m个台阶,f[i]保存爬n个台阶的爬法总数,返回f[n] * 优化版O(n) */ long long PaLouTi(const int n, const int m, long long * const f) { int i; f[0] = f[1] = 1; for (i = 2; i

2010-08-02 18:54:00 3742 1

原创 PKU 1862 Stripies

通过这道题学会了简单的使用STL中的优先级队列priority_queue。题目大意:给定一个包含若干个数的集合,每次抽出两个数a和b,通过公式2*sqrt(a*b)得到的新值放回集合。直到集合中剩余1个元素。求这个“剩余元素”的最小值。思路:通过简单的推导,容易知道:若想使得“剩余元素”值最小,每次抽出的两个数a和b值要最大。所以想到了“大根堆”这种数据结构。#include #include #include #include #include #include #include

2010-07-08 18:57:00 592

原创 PKU 2190 ISBN

特别注意'X':(1) 当问号出现在末尾,它可能是0~9,X(2) 当问号出现在其它位置,它可能是0~9,不可以是X#include #include #include #include #include #include using namespace std; int main() { char str[20]; gets(str); int q; int sum = 0; for (int i = 0; i

2010-07-07 12:57:00 577

原创 PKU 1657 Distance on Chessboard

<br />注意起点与终点相同的情况<br />/* 1657 Distance on Chessboard */ #include <iostream> #include <cstdio> #include <cstdlib> #include <string> #include <cmath> using namespace std; int max(int a, int b) { return a > b ? a : b; } int main() { int x1, y

2010-07-06 13:53:00 519

原创 PKU 1552 Doubles

先排序#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int num[100]; cin >> num[0]; while (num[0] !=

2010-07-06 13:42:00 469

原创 PKU 2136 Vertical Histogram

<br />使用strncpy去除后面的空格<br />/* 2136 Vertical Histogram */ #include <iostream> #include <cstdio> #include <cstdlib> #include <cctype> #include <string> #include <cstring> using namespace std; inline void RemoveEndSpace(char * str1, char * str2) {

2010-07-06 13:38:00 399

原创 PKU 2419 Forest

<br />使用了bitset解决<br />/* 2419 Forests */ #include <iostream> #include <cstring> #include <cstdio> #include <cstdlib> #include <bitset> using namespace std; const int MAX = 105; int main() { bitset<MAX> person[MAX]; int per, tree; int a, b;

2010-07-06 13:36:00 582

原创 巧用bitset解决PKU2105水题(IP地址问题)

2010-05-03 21:51:00 534

原创 字符串中删除固定字符

2009-05-02 17:42:00 436

SGU离线题库(完整530道题,带试题难度排序)

辛苦整理所得,分略多,绝对值得,sgu完整题库(530个网页,还有试题难度排序)。lnddszp[at]gmail[dot]com

2011-06-21

空空如也

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

TA关注的人

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