很简单的一道动态规划,而且没有打印路径 我的思路也是来自《算法导论》,但是看了一个台湾朋友的博客才算是明白了一点点。 他是这么想的,将两个字符串各取最后一个的e1,e2,这样原字符串可以表示为sub1+e1,sub2+e2,
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;
char X[1000];
char Y[1000];
int C[1000][1000];
int LCS(char* X,char* Y,int m,int n)
{
for(int i=1;i<=m;i++)
C[i][0]=0;
for(int i=0;i<=n;i++)
C[0][i]=0;
for(int i=1;i<=m;i++)
for(int j=1;j<=n;j++)
{
if(X[i-1]==Y[j-1])
C[i][j]=C[i-1][j-1]+1;
else if(C[i-1][j]>=C[i][j-1])
C[i][j]=C[i-1][j];
else
C[i][j]=C[i][j-1];
}
return C[m][n];
}
int main()
{
freopen("in.txt","r",stdin);
while(cin>>X>>Y){
int m=strlen(X);
int n=strlen(Y);
int ans=LCS(X,Y,m,n);
printf("%d\n",ans);
memset(X,0,sizeof(X));
memset(Y,0,sizeof(Y));
memset(C,0,sizeof(C));
}
}
后来再补充!
#关于本博客
首先,感谢我的同学–刘欢,这个模板就是copy他的repo,回想从大一伊始,他没少在计算机的路上带我,感谢!!! 为了表达对它的敬意,他前面的文章我保留了,在2014-07之前,本博客所写的文章均出自bitsly,转载请注明。
本配置适用于debian9,图形界面使用的是xfce4.8,编辑器默认使用xfce中的mousepad。 其中$、#是提示符,表示当前终端账户是普通还是root,并不需要输入。
以下所有操作均使用root
权限。
在终端下输入并回车
$ su root
然后输入root的密码(安装debian时设定的,区别于普通用户密码)
编辑使用图形界面下的文本编辑器如xfce下的mousepad.如果使用其他的,则将mousepad换成别的即可。
mousepad /etc/apt/sources.list
在文件最前面添加以下条目
deb http://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib
deb http://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib
deb http://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ stretch main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ stretch-updates main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian/ stretch-backports main non-free contrib
deb http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free contrib
deb-src http://mirrors.ustc.edu.cn/debian-security/ stretch/updates main non-free
关闭文本编辑器,然后在终端中输入
apt-get update
安装文泉宋体
apt-get install xfonts-wqy ttf-wqy-zenhei ttf-wqy-microhei
安装uming宋体
aptitude install fonts-arphic-uming ttf-arphic-uming
安装外来字体
把字体文件(比如simsun.ttc)直接cp 到 ~/.fonts下,即可。
要支持区域设置,首先要安装locales软件包:
apt-get install locales
然后配置locales软件包:
dpkg-reconfigure locales
在界面中钩选上 zh_CN.UTF-8
,确定,在接下来的选项中也选择 zh_CN.UTF-8
然后重启,到这里应该就可以显示中文了
sudo可以让非root用户具有管理员的权限,安装好的Debian后还不能使用sudo,需要使用root用户登陆后安装sudo命令。
apt-get install sudo
安装后,就可以给你的帐号设置管理员权限了
mousepda /etc/sudoers
在 root ALL=(ALL:ALL) ALL 的下一行,添加一行
username ALL=(ALL:ALL) ALL
这里的username就是你要给予一定权限的用户 然后保存,退出root,然后使用username用户登陆。应该就有sudo权限了。
确定电脑是使用的NVDIA卡再装,因为NVDIA的驱动之前一直是闭源的,近期才向开源社区提供,所以不能保证百分百的支持所有显卡.如果安装完后无法进入桌面的话就说明不支持你的显卡,还是重装使用默认的驱动好了.
apt-get install nvidia-glx nvidia-kernel-dkms nvidia-xconfig nvidia-settings
nvidia-xconfig
Update: 这块的教程没有及时更新,请大家认真参考其他资料
mousepad /etc/X11/xorg.conf
找到这一段。
Section "Screen"
Identifier "Screen0"
Device "Device0"
……
Option "RegistryDwords" "EnableBrightnessControl=1"
EndSection
即在EndSection前添加“Option "RegistryDwords" "EnableBrightnessControl=1"”
这一行,最好加在指定行!!!不然可能无效
然后保存,退出,重启之后,你就会发现可以调节屏幕背光亮度了。
mousepad /usr/share/X11/xorg.conf.d/10-evdev.conf
修改这里(里面的配置很像、主要Identifier部分来辨别到底改哪的部分)
Section "InputClass"
Identifier "evdev touchpad catchall"
MatchIsTouchpad "on"
MatchDevicePath "/dev/input/event*"
Driver "synaptics"
Option "TapButton1" "1"
Option "TapButton2" "2"
Option "TapButton2" "3"
EndSection
安装laptop-mode-tools
apt-get install laptop-mode-tools
编辑配置
mousepad /etc/hdparm.conf
将后面的配置修改为下面配置
/dev/hda {
mult_sect_io = 16
write_cache = off
dma = on
apm = 255
apm_battery = 127
}
安装fcitx
apt-get install fcitx fcitx fcitx-googlepinyin
安装im-switch
apt-get install im-switch
apt-get install build-essential linux-headers-$(uname -r)
1.切换到deb包目录下
dpkg -i google-chrome-stable_amd64.deb
这时会提示错误,依赖关系没有满足,无法安装。
2.接下来,我们解决依赖关系。
apt-get -f install
这样,就会先自动安装依赖的软件包,然后自动安装好deb包.
3.如果想卸载deb安装的包,先要确定安装的名字,如Chrome就是在终端中可以执行的名字
dpkg -r chrmoe
apt-get install chromium-browser chromium-browser-l10n
apt-get install iceweasel-l10n-zh-cn
运行浏览器,然后点击 浏览器菜单 ===> 编辑 ===> 首选项 ===> 内容 设置浏览器字体
apt-get install gnash browser-plugin-gnash
apt-get install unrar unzip p7zip-full
apt-get install git bzr mercurial
对ntfs分区有危险,常常让ntfs分区的文件损坏.慎重使用。
apt-get install ntfs-3g
dpkg --add-architecture i386
安装后 apt 会把 i386 的软件包一起 cache 起来,执行:
apt-get update
完成后就可以安装 ia32-libs 了:
apt-get install ia32-libs ia32-libs-gtk
安装后只要依赖关系满足,32 位的程序就能正常运行了。
如果以后不想要 i386 支持了,只要运行:
dpkg --remove-architecture i386
在http://www.foxitsoftware.cn/downloads/中->福昕阅读器 -> Desktop Linux -> bz2 下载 FoxitReader-1.1.0.tar.bz2 解压到 /usr/local 中
tar -jxvf FoxitReader-1.1.0.tar.bz2 -C /usr/local
重命名文件夹
mv /usr/local/1.1-release /usr/local/FoxitReader
在 /usr/local/bin 中添加访问路径
ln -s /usr/local/bin /usr/local/FoxitReader/FoxitReader
外接显示器在右侧拓展:
xrandr --output LVDS-0 --auto --left-of VGA-0
外接显示器在左侧拓展:
xrandr --output VGA-0 --auto --left-of LVDS-0
也可以使用arandr通过图形界面来配置双屏幕
apt-get install arandr
这里使用audacious软件
apt-get install audacious
这里使用shutter软件
apt-get install shutter
这是我这篇文章修改的原因,如果大家知道自己计算机使用的什么厂商的无线网卡最好不过了,否则就使用
apt get install firmware-*
这样就把一些硬件的驱动安装进来。