自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 玛雅人的密码bfs

如何用队列广度优先遍历所有可能性(QUEUE) + 如何判别并标示某串是否访问过(MAP) + 如何记录某串已经交换字符的次数 + 子串2012是否存在#include <iostream>#include <string>#include <map>#include <cstdio>#include <cstring>#include <queue>using namespace st

2018-02-28 23:38:01 411

原创 二叉树遍历已知先序求中序

#include <iostream>#include <cstdio>#include <cstring>using namespace std;struct Node{ char c; Node *left,*right;};char s[105];void build(Node *&root,int &index,int n){ if(index==n)

2018-02-28 23:07:42 726 1

原创 拆分为2的幂的和的种数

https://www.nowcoder.com/practice/376537f4609a49d296901db5139639ec?tpId=40&tqId=21339&tPage=1&rp=1&ru=%2Fta%2Fkaoyan&qru=%2Fta%2Fkaoyan%2Fquestion-ranking 有递推关系 当n=2k+1为奇数时,f(2k+1)=f(2k)。差别在于奇数多一个1

2018-02-27 21:21:31 592

原创 分解质因子

https://www.nowcoder.com/practice/20426b85f7fc4ba8b0844cc04807fbd9?tpId=40&amp;tqId=21338&amp;tPage=1&amp;rp=1&amp;ru=/ta/kaoyan&amp;qru=/ta/kaoyan/question-ranking 求正整数N(N&gt;1)的质因数的个数。 相同的质因数需要重复计算...

2018-02-27 20:56:01 488

原创 dp常见问题

poj1163 http://poj.org/problem?id=1163 数塔 dp[i][j]=max(dp[i-1][j-1],dp[i-1][j])+a[i][j];#include &lt;iostream&gt;#include &lt;cstring&gt;using namespace std;int a[105][105];int dp[105][1...

2018-02-27 20:23:36 732

原创 数串 组成最大整数

https://www.nowcoder.com/practice/a6a656249f404eb498d16b2f8eaa2c60?tpId=85&tqId=29898&tPage=4&rp=4&ru=/ta/2017test&qru=/ta/2017test/question-ranking设有n个正整数,将他们连接成一排,组成一个最大的多位整数。 如:n=3时,3个整数13,312,343,

2018-02-25 23:50:00 323

原创 hdu2031进制转换

#include <iostream>#include <cstdio>#include <cmath>using namespace std;int main(){ int n,r; int a[1000]; while(cin>>n>>r) { if(n<0) { n=-n;

2018-02-20 16:07:35 434

原创 hdu3783 ZOJ字符串处理

#include <iostream>#include <cstring>#include <cstdio>#include <cmath>using namespace std;int main(){ char s[105]; while(cin>>s&&s[0]!='E') { int z=0,o=0,j=0; int len=s

2018-02-11 00:01:22 295

原创 hdu1880魔咒词典

用map超内存,暴力写 MLE#include <iostream>#include <cstring>#include <cstdio>#include <map>#include <string>using namespace std;map<string,string>m1;map<string,string>m2;map<string,string>::iterator it

2018-02-08 12:23:40 350

原创 hdu1879继续畅通工程

模板,已经建好的路让其值为0即可#include <iostream>#include <cstdio>#include <algorithm>using namespace std;int pre[1005];int n;struct node{ int a,b,l,f;}c[5000];bool cmp(node x,node y){ return x.l<y.l;

2018-02-08 10:20:24 225

原创 hdu1878欧拉回路

无向图欧拉回路的条件 1. 连通 2. 所有结点度为偶数 #include <iostream> #include <cstdio> #include <cstring> using namespace std; int pre[1005]; int deg[1005]; int n,m; void init() {

2018-02-08 10:02:20 143

原创 hdu1877进制转换

#include <iostream>#include <cstdio>using namespace std;int a[100];int main(){ long long A,B,sum; int m; while(cin>>m,m) { int i=0; scanf("%I64d%I64d",&A,&B);

2018-02-05 23:55:01 182

原创 手机键盘 模拟

题目描述 按照手机键盘输入字母的方式,计算所花费的时间 如:a,b,c都在“1”键上,输入a只需要按一次,输入c需要连续按三次。 如果连续两个字符不在同一个按键上,则可直接按,如:ad需要按两下,kz需要按6下 如果连续两字符在同一个按键上,则两个按键之间需要等一段时间,如ac,在按了a之后,需要等一会儿才能按c。 现在假设每按一次需要花费一个时间段,等待时间需要花费两个时间段。 现在给出一串字符

2018-02-04 22:31:04 1260

原创 hdu2602 01背包

01背包模板,只是存在体积为0的物品且有价值#include <iostream>#include <cstdio>#include <cstring>using namespace std;const int maxn=1010;int v[maxn];int w[maxn];int dp[maxn][maxn];int main(){ int t; int n,c;

2018-02-03 23:51:02 110

原创 01背包

n个物品重量为w[i],价值为v[i],有容量为m的袋子,最多能得的价值,记得以前分不清他和贪心的区别,贪心法是每一步的最优解就是整体的最优解(局部最优)。01背包是属于动态规划,每一步的解不一定导致整体的最优解(整体最优),由于物体不可分割,贪心算法可能最后会有缝。学习了其他人的文章,例子题目描述: 假设山洞里共有a,b,c,d ,e这5件宝物(不是5种宝物),它们的重量分别是2,2,6,...

2018-02-03 23:49:19 342

原创 hdu1862结构体中string成员之内存泄漏

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>using namespace std;struct stu{ string num,name; int grade;} a[100100];bool cmp1(stu a,stu b){

2018-02-01 23:03:00 430

空空如也

空空如也

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

TA关注的人

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