文章列表
#include <iostream>
#include <cstdio>
#include <cstring>
struct Tree{
int father;
int child;
int brother;
int NOT;
int s;
int Max(){
return s > NOT ? s : NOT;
}
void Init(){
father=child=brother=NOT=0;
}
}tree[60001]; ...
完全背包 poj 2063 Investment
- 博客分类:
- 动态规划
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int c[20];
int I[20];
int dp[50050];
int main()
{
int rest,capital,t,year,bnum;
scanf("%d",&t);
while(t--)
{
rest=0;
capital=0;
year=0;
...
lld exp_mod(lld a,lld b,lld c)
{
lld ans=1;
lld temp=a%c;
if(b==0) return 1;
while(b)
{
if(b&1) ans=ans*temp%c;
temp=temp*temp%c;
b>>=1;
}
return ans;
}
数位dp_HDOJ_3555_bomb
- 博客分类:
- 动态规划
Bomb
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others)
Total Submission(s): 876 Accepted Submission(s): 319
Problem Description
The
counter-terrorists found a time bomb in the dust. But this time the
terrorists improve on the time bomb. The number s ...
统计1的个数
int count(int x)
{
int res=0;
while(x){
res++;
x&=x-1;
}
return res;
}
http://www.cppblog.com/staryjy/archive/2010/09/25/101412.html
#include <iostream>
#include <string>
using namespace std;
int dp[1050][1050];
int main()
{
string a,b;
while(cin>>a>>b)
{
memset(dp,0,sizeof(dp));
for(int i=1;i<=a.size();i++)
{
for(int j=1;j<=b.size();j++)
...
编辑距离;
来自wiki的编辑距离介绍
编辑距离
,又称Levenshtein距离
,是指两个字串
之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符
,删除一个字符。
例 ...
代码能力:50+;
动态规划:
数位dp:HDOJ 3555 bomb 简单数位dp:http://acm.hdu.edu.cn/showproblem.php?pid=3555
dp中的双向问题:2
编辑距离:1;
LIS类问题;2;
POJ 1887 Testing the CATCHER http://poj.org/problem?id=1887
POJ 2533 Longest Ordered Subsequence http://poj.org/problem?id=2533
LCS问题:1;
poj-1159-Palindrome http://poj ...