向这位努力了一年的大一就进总决赛的大牛学习。线段树专辑大全进入它的博客后 在右边推荐文章里点《完全版线段树》注意有些浏览器打不开这个网站,据我所知,谷歌浏览器,搜狗浏览器 可以用。大牛博客:www.notonlysuccess.com Read More
posted @ 2012-07-04 22:34 To be an ACMan Views(414) Comments(0) Diggs(1)
这题是最大子序列和(hdu1003)的拓展。先复习一下最大子序列和(DP,hdu1003)吧:思路:用dp[i]表示以第i个数为结尾的子序列和最大值;状态转移方程:dp[i]=a[i] (dp[i-1]<0)dp[i]= dp[i-1]+a[i] (dp[i-1]>=0)这是有数组的做法。程序本人不提供下面提供一个无数组的代码,其实思想还是一样的hdu1003hdu1003#include<stdio.h>int main(){ int n,s,e,max,maxs,maxe,i,num,T,sum,u=0; scanf("%d",&T); Read More
posted @ 2012-07-01 17:08 To be an ACMan Views(1845) Comments(1) Diggs(1)
很有技巧的一道数学题。本题思路:假设要求的数字为A,去除的为第k位,那么按照这个规则,将A划分为三段:高位c,k位b,低位a,则x=a*10^(k+1)+b*10^k+c去除后为B=a*10^k+c,那么n=A+B=(11a+b)*10^k+2c;但是由于2c有可能带来进位,可能会使b进1,但是不会对a出现影响,那么a就可以直接求出了。再通过a求出b,然后求出c;求c时分进位和没有进位两种情况,记录下来,然后排序一下输出。View Code #include<stdio.h>#include<algorithm>using namespace std;int main( Read More
posted @ 2012-06-30 17:48 To be an ACMan Views(174) Comments(0) Diggs(0)
排序+二分查找:http://acm.pku.edu.cn/JudgeOnline/problem?id=1318最小公倍数:http://acm.zju.edu.cn/show_problem.php?pid=1797数列的周期性:http://acm.zju.edu.cn/show_problem.php?pid=2105数三角形:http://acm.zju.edu.cn/show_problem.php?pid=1629高精度加法:http://acm.zju.edu.cn/show_problem.php?pid=1292非10进制高精度加法:http://acm.zju.edu.c Read More
posted @ 2012-06-29 22:19 To be an ACMan Views(399) Comments(0) Diggs(0)
题目来源:http://acmpj.zstu.edu.cn/JudgeOnline/showproblem?problem_id=2552动态规划基本步骤(本人觉得):1.确定数组的维数,一维,二维等等;2.弄清数组下标的含义3.找出状态转移方程式;4实现自己的想法;本题思路:二维数组dp[i][j],i表示前i个马棚放马完毕,j表示队列前j匹马已经进入马棚,dp[i][j]记录前j匹马放在前i个马棚里的最小不愉快系数,用f(a,b)表示只把第a匹马到第b匹马放在一个马棚里的不愉快系数;思考得出 状态转移方程:dp[i][j]=min(dp[i-1][t]+f(t,j));注意范围:(i-1& Read More
posted @ 2012-06-29 15:03 To be an ACMan Views(301) Comments(0) Diggs(0)
DP+DFS,记忆化搜索,典型的用空间换时间。View Code #include<stdio.h>#include<string.h>int dp[101][101],h[101][101];int dir[4][2]={1,0,-1,0,0,1,0,-1};int m,n;int dfs(int x,int y){ if(dp[x][y])return dp[x][y]; int i,temp; for(i=0;i<4;i++) { int fx=x+dir[i][0]; int fy=y+dir[i][1]; if(fx>... Read More
posted @ 2012-06-02 22:34 To be an ACMan Views(178) Comments(0) Diggs(0)
经典三维BFS,此题用DFS会超时,用BFS不剪枝也会超时,其实跟二维的BFS没什么区别View Code #include<stdio.h>#define maxn 31struct node{ int x,y,z; int cnt;};const int dir[6][3]={{0,-1,0},{-1,0,0},{0,1,0},{1,0,0},{0,0,-1},{0,0,1}};int map[maxn][maxn][maxn];int a,b,c,t;int bfs(){ node q[maxn*maxn*maxn]; node n,p; int i,rea... Read More
posted @ 2012-06-02 20:41 To be an ACMan Views(176) Comments(0) Diggs(0)
zstu2511-Delete Number题目来源:http://acmpj.zstu.edu.cn/JudgeOnline/showproblem?problem_id=2511View Code #include<stdio.h>#include<string.h>int main(){ int n,num,T,i; char s[1001]; scanf("%d",&T); while(T--) { scanf("%d%s",&n,s); num=strlen(s); int cnt=0,x=0,y=1;/ Read More
posted @ 2012-05-31 23:07 To be an ACMan Views(345) Comments(0) Diggs(0)
vector(向量): C++中的一种数据结构,确切的说是一个类.它相当于一个动态的数组,当程序员无法知道自己需要的数组的规模多大时,用其来解决问题可以达到最大节约空间的目的.用法:1.文件包含:首先在程序开头处加上#include<vector>以包含所需要的类文件vector还有一定要加上using namespace std;2.成员函数1.push_back 在数组的最后添加一个数据2.pop_back 去掉数组的最后一个数据 3.at 得到编号位置的数据4.begin 得到数组头的指针5.end 得到数组的最后一个单元+1的指针6.front 得到数组头的引用7.back Read More
posted @ 2012-05-30 22:04 To be an ACMan Views(2270) Comments(0) Diggs(1)
STL简介1 概况.......................................................... 21.1 STL是什么............................................... 21.2 为什么我们需要学习STL................................... 21.3 初识STL................................................. 21.4 STL 的组成.............................................. 5 Read More
posted @ 2012-05-30 21:18 To be an ACMan Views(3149) Comments(1) Diggs(0)