码迷,mamicode.com
首页 >  
搜索关键字:code    ( 108667个结果
模板:三大基础背包
1 void ZeroOnePack(int cost,int value){//01 2 for(int j=v;j>=cost;j--){ 3 dp[j]=max(dp[j],dp[j-cost]+value); 4 } 5 } 6 7 void CompletePack(int cost,in... ...
分类:其他好文   时间:2017-10-14 17:06:54    阅读次数:180
模板:扩展欧几里得
1 typedef long long LL; 2 3 LL e_gcd(LL a,LL b,LL &x,LL &y){ 4 LL d=a; 5 if(b!=0){ 6 d=e_gcd(b,a%b,y,x); 7 y-=(a/b)*x; 8 } 9 else{x=1;y=0;} 10 return.... ...
分类:其他好文   时间:2017-10-14 17:06:23    阅读次数:153
C语言实现管道通讯
mkfifo.c文件 link.h文件 link.c文件 write.c文件 read.c文件 gcc mkfifo.c ./aou.t 生成 test gcc link.c write.c -o write gcc link.c read.c -o read 运行read和write,效果如下图: ...
分类:编程语言   时间:2017-10-14 17:04:28    阅读次数:292
模板:Manacher算法(马拉车算法)
1 //Manacher算法 求最长回文子串 2 int Init(){ 3 int len=strlen(s); 4 s_new[0]='$';s_new[1]='#'; 5 int j=2; 6 for(int i=0;i<len;i++){ 7 s_new[j++]=s[i]; 8 s_new... ...
分类:编程语言   时间:2017-10-14 17:02:36    阅读次数:211
python day3
目录: 1.集合 2.文件操作 3.编码转换 4.函数 一.集合 集合是无序的 执行结果: 执行结果: 执行结果: 执行结果: 二.文件操作 open文件的读写追加参数: r :读模式 w:写模式(清空原内容,在写入) a:末尾追加模式 打开并读取文件: 打开文件追加内容 注意with open() ...
分类:编程语言   时间:2017-10-14 17:01:21    阅读次数:169
模板:欧拉函数
1 //直接求解欧拉函数 2 int Euler(int n){ 3 int res=n,a=n; 4 for(int i=2;i*i1) res=res/a*(a-1); 11 return res; 12 } 13 14 //筛法求解欧拉函数 15 void Euler(){ 16 phi[1]... ...
分类:其他好文   时间:2017-10-14 16:51:42    阅读次数:148
模板:快速幂
1 //普通快速幂 2 typedef long long LL; 3 LL fast_mod(LL x,LL n,LL mod){ 4 LL ans=1; 5 while(n>0){ 6 if(n&1) ans=(ans*x)%mod; 7 x=(x*x)%mod; 8 n>>=1; 9 } 10... ...
分类:其他好文   时间:2017-10-14 16:49:12    阅读次数:138
模板:逆元求解
1 //费马小定理 inv(a) = a^(p-2) (mod p),保证a,p互质,并且p是素数的情况下使用,局限性有点大。 2 LL fast_mod(LL x,LL n,LL mod){ 3 LL ans=1; 4 while(n>0){ 5 if(n&1) ans=(ans*x)%mod; ... ...
分类:其他好文   时间:2017-10-14 16:48:46    阅读次数:153
Mysql高效插入/更新数据
从tushare抓取到的财务数据,最开始只是想存下来,用的办法想简单点,是:插入--报错—update 但发现这个方法太蠢,异常会导致大量无效连接,改为: for idx,row in d2.iterrows(): try: rs=db.getData("select f_Code,f_Time,%... ...
分类:数据库   时间:2017-10-14 15:07:38    阅读次数:172
字符的编码和解码
字符的编码和解码 ...
分类:其他好文   时间:2017-10-14 14:57:08    阅读次数:103
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!