题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4722
思路:数位dp,dp[i][j]表示到第i位,数字和%10为j,然后进行dp,注意完全匹配的情况是要+1,而其他情况是从0 到 9 都要考虑
代码:
#include
#include
#include
#include
using namespace std;
int t;
l...
分类:
其他好文 时间:
2014-05-07 04:55:37
阅读次数:
314
形态:
实现:/*****************************************
稀疏矩阵的三元组顺序表存储表示
by Rowandjj
2014/5/3
******************************************/
#include
using namespace std;
#define MAXSIZE 12500//非零元个数的最大值
...
分类:
其他好文 时间:
2014-05-07 04:42:40
阅读次数:
387
人控制方向:
#include
using namespace std;
#define n 8
int * createMaze(){
int i,j;
int * a;
a=new int[n*n];
for(i=0;i<n;i++){
for(j=0;j<n;j++){
*(a+n*i+j)=0;
}
}
*(a+n*0+1)=3;
*(a+n*1+1)=1;...
分类:
其他好文 时间:
2014-05-07 03:10:02
阅读次数:
319
#include
using namespace std;
class CPerson
{
protected:
string m_szName;
string m_szId;
int m_nSex;//0:women,1:man
int m_nAge;
public:
CPerson(string name,string id,int...
分类:
其他好文 时间:
2014-05-07 03:04:18
阅读次数:
239
《算法导论》里的COUNTING_SORT,用C++实现有问题:
#include
#include
using namespace std;
void COUNTING_SORT(vectorint>&A, vectorint>&B, const int& k)
{
int* C = new int[k + 1]();
for (unsigned j = 0; j A.size();...
分类:
其他好文 时间:
2014-05-07 02:59:30
阅读次数:
251
枚举+二分查找。
A+B+C >= K ----> C >= K - A -B ----> 统计大于等于C的个数即可。
#include
#include
#include
#include
#include
#include
using namespace std;
int a[1010];
int Scan() //输入外挂
{
int...
分类:
其他好文 时间:
2014-05-07 02:52:11
阅读次数:
322
用栈实现括号匹配其实是一个很简单的问题,思路在代码注释里面写的很清楚了,只是接口设置的好像不太好。
如果在main里面设置的str不是动态分布的,在linux下就会出错,不知道windows会不会出问题。
kuohao.cpp
#include
#include "stack.cpp"
using namespace std;
//仅用于检测(),{},[],其他的符号原理都是一样的
bo...
分类:
其他好文 时间:
2014-05-07 02:39:17
阅读次数:
247
#include
using namespace std;
class Stu //声明基类
{
public:
Stu(int n, string nam ); //基类构造函数
void display( ); //成员函数,输出基类数据成员
protected: //(*)访问权限为保护型的数据成员
int nu...
分类:
其他好文 时间:
2014-05-06 23:20:29
阅读次数:
296
首先是活动安排问题。
贪心的关键在于排序策略。
思路很简单,对所有活动的结束时间排序,如果结束时间相同,因为要尽量多的参加活动,所以选取开始时间尽量晚的(这样可以安排的比较多),然后依次从早到晚选取不冲突的活动加入,即为最多可以参加的活动。
#include
#include
#include
#include
#include
using namespace std;
clas...
分类:
其他好文 时间:
2014-05-06 23:01:00
阅读次数:
394
今天学习了python的输入输出、异常处理和python标准库1.文件通过创建一个file类的对象去处理文件,方法有read、readline、write、close等[root@reed0505]#catusing_file.py
#!/usr/bin/python
#filename:using_file.py
poem=‘‘‘Programingisfun
whentheworkisdone
usePython!..
分类:
编程语言 时间:
2014-05-06 17:05:03
阅读次数:
448