STL初步 不定长数组:vector(算法竞赛入门经典读书笔记)
王大头不吃藕
vectorSTL初步
STL是指C++的标准模板库(StandardTemplateLibrary)不定长数组:vector声明:vectora;//类似于chara[]vectorb;//类似于intb[]使用前记得加头文件:#include或者直接用万能头文件咯:#include常用操作:代码作用a.push_back()向尾部添加元素a.pop_back()删除最后一个元素a.resize()改变大小a.size
算法竞赛入门经典习题1-5 打折
宜修
算法竞赛入门经典算法C语言
一件衣服95元,若消费满300元,可打八五折。输入购买衣服件数,输出需要支付的金额(单位:元),保留两位小数#include#includeintmain(){intn;printf("你要购买的衣服件数为:");scanf("%d",&n);if(n*95>=300)printf("您需付%.2f元",n*95*0.85);elseprintf("您需付%.2f元",n*95);return0;
算法竞赛入门经典习题2-4 子序列的和(subsequence)
宜修
算法竞赛入门经典C语言
输入两个正整数n<m<106,输出,保留5位小数。输入包含多组数据,结束标记为n=m=0。提示:本题有陷阱。样例输入:246553665536000样例输出:Case1:0.42361Case2:0.00001#includeintmain(){__int64n,m,i,kase=0;while(scanf("%I64d%I64d",&n,&m)==2&&n&&m){doublesum=0.0;k
算法竞赛入门经典之求圆柱体的体积
yamotl
笔记
#include#includeintmain(){constdoublepi=acos(-1.0);//用来求常数派doubler,h,s1,s2,s;scanf("%lf%lf",&r,&h);//lf表示double型的输入s1=pirr;s2=2pirh;s=s12.0+s2;printf(“Area=%.3f\n”,s);return0;}
算法竞赛入门经典求三个整数的平均数
yamotl
笔记
//求三个整数的平均值,其实这个代码写错了,因为输入的abc并非整数,将3改成3.0,即使abc是整数,得出的仍旧为double型#include#includeintmain(){doublea,b,c;scanf("%lf%lf%lf",&a,&b,&c);doubles;s=(a+b+c)/3;printf("%.3lf\n",s);return0;}可以看一个学长的正确代码
ACM模板
木若流兮
ACM模板ACM模板
ACM题集以及各种总结大全!一.ACM入门关于ACM百度百科连接杭州电子科技大学(hdu)ACM题目连接关于acm的帮助连接北京大学(poj)题目连接浙江大学(zoj)题目连接uva题目连接青理工大学acm宣传ppt(据说就是耀哥的魅力害了好多人来搞ACM)连接二.水题hdu水题分类之耀哥版poj题目分类小媛在努力原创《算法竞赛入门经典》刘汝佳白皮书第五章题目链接《算法竞赛入门经典》刘汝佳白皮书第
【算法竞赛入门经典例题题解】 【DP】练习城市里的间谍 A Spy in the Metro UVA1025 UVA437 巴比伦塔 刘汝佳
CCSU__LRF
算法c语言动态规划
【算法竞赛入门经典例题题解】【DP】UVA1025练习城市里的间谍ASpyintheMetro洛谷链接UVA1025练习城市里的间谍ASpyintheMetro题目某城市地铁是一条直线,有nn(2\leqn\leq502≤n≤50)个车站,从左到右编号…n。有M1辆列车从第1站开始往右开,还有M2辆列车从第n站开始往左开。列车在相邻站台间所需的运行时间是固定的,因为所有列车的运行速度是相同的。在时
算法竞赛入门经典(第二版)-刘汝佳-第六章 数据结构基础 例题(18/22)
梁山伯liangrx06
算法竞赛入门经典uva算法算法竞赛入门经典数据结构acm
文章目录说明例题例6-1UVA210并行程序模拟(p139,双端队列)例6-2UVA514铁轨(p140,栈)例6-3UVA442矩阵链乘(p141,用栈实现简单的表达式解析)例6-4UVA11988破损的键盘(p143,链表)例6-5UVA12657移动盒子(p144,双向链表)例6-6UVA679小球下落(p148,完全二叉树编号)例6-7UVA122树的层次遍历(p150,二叉树的动态创建于
蓝桥杯备考——算法竞赛入门经典(第2版)学习笔记2
不好好学习是猪
算法竞赛入门经典(第2版)学习笔记2第二章循环结构程序设计2.1for循环2.2while循环和do-while循环2.3循环的代价2.4算法竞赛中的输入输出框架2.5注解与习题第二章循环结构程序设计2.1for循环例题2-1aabb输出所有形如aabb的4位完全平方数(即前两位数字相等,后两位数字也相等)分析:第一种思路(1)首先枚举所有可能的aabb,然后判断他们是否为完全平方数注:a的范围是
位数(digit),计算一个整数是几位数(C++)
小鱼儿Melody
C++算法刘汝佳c++算法
计算一个整数是几位数(C++)文章目录计算一个整数是几位数(C++)前言题目:解题思路:代码:运行结果总结前言刘汝佳算法《算法竞赛入门经典》第二章2.4.6上机练习第一题题目:输入一个不超过10的九次方的正整数,输出它的位数。例如:12735的位数是5.请不要使用任何数学函数,用四则运算和循环语句实现。解题思路:判断位数可以从第一位开始数也可以从最后一位开始数。从一个整数中获取其中一位数可以用除法
[刷题]算法竞赛入门经典(第2版) 5-8/UVa230 - Borrowers
蟹恼板
刷题算法竞赛入门经典(第2版)UVaACM算法竞赛入门经典
//又开学啦,不知不觉成为大二的老人了。。。时间过得好快啊,感觉好颓废。。。题意:建立一个借书/归还系统。有借、还、把还的书插到书架上这三个指令。代码:(Accepted,0ms)//UVa230-Borrowers#include#include#include#includeusingnamespacestd;structBOOK{stringau,ti;BOOK(conststring&a,
学习路线规划
RecCall
目前有两本书,《算法竞赛入门经典》和《算法竞赛进阶指南》。根据书名应该先看《算法竞赛入门经典》(《算法竞赛入门经典》有三部分,包括语言篇、基础篇和竞赛篇。开学前争取完成第一部分吧——语言,知识点很简单;累的地方是做习题。剩下的,《组合数学》得看。《C++Primer》得看。至于深入部分,以后再说吧。
Go语言开发工具-Goland安装教程,算法竞赛入门经典java版
m0_64384202
程序员面试java后端
选择版本进行下载:教程:先下载Windows版的Goland开发工具:Next:设置安装路径,然后Next:勾选配置,然后Next:
UVa 12096 - The SetStack Computer
yaoyuan-yy
请看rujia大神的《算法竞赛入门经典第2版》P115~117#include#include#include#include#include#include#include#defineALL(x)x.begin(),x.end()#defineINS(x)inserter(x,x.begin())usingnamespacestd;typedefsetmyset;mapidcache;vect
【算法竞赛入门经典】习题3-8 循环小数(Repeating Decimals,ACM/ICPC World Finals 1990,UVa 202)
菜鸟的打怪升级
算法竞赛入门经典
QThedecimalexpansionofthefraction1/33is0.03,wherethe03isusedtoindicatethatthecycle03repeatsindefinitelywithnointerveningdigits.Infact,thedecimalexpansionofeveryrationalnumber(fraction)hasarepeatingcyc
c语言buffer在scanf里,C语言中scanf函数与输入缓冲区
18108166336
-讨论下scanf函数,输入缓冲区的关系样例来源于算法竞赛入门经典第一章实验部分的内容,经过测试发现scanf函数对于整形数据在读入时会过滤掉空格符、换行符和水平制表符。按照提示,如果b的值非法,比如说输入一个字符‘s’,那么会出现什么结果呢?voidscanf_buffer(void){inta,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d%d\n",a
算法竞赛入门经典 习题5-16
RayoNicks
《算法竞赛入门经典》算法
UVa212UseofHospitalFacilities医院包含手术室和恢复室两种类型的房间,病人需要先在手术室进行手术,然后转移到恢复室中恢复,病人只可能在由于手术室不足而等待,而不回因为恢复室不足而等待。给定每个病人的手术时间和恢复时间,模拟医院的业务流程,并打印每个手术室和每个恢复室的统计信息。借鉴习题5-13的思路,在每个会发生事件的时间点对病人、手术室和恢复室进行调度即可。这里首先定义
UVA-1602 网格动物 题解答案代码 算法竞赛入门经典第二版
漂流瓶jz
算法竞赛入门经典算法c++数据结构算法竞赛入门经典aoapcdfsPolyomino
GitHub-jzplp/aoapc-UVA-Answer:算法竞赛入门经典例题和习题答案刘汝佳第二版使用dfs遍历所有情况,再去重即可。遍历部分遍历的时候需要注意:1.这其实并不能算是dfs,因为普通的dfs是一直走到尽头,然后再逐渐退出,走下一条路。到最后的路径是一条线。但是这个题目生成的图形却可以分叉。因此,递归一次dfs时,要循环遍历当前所有的节点,让所有的节点都可以分叉进行。2.如果直接
问题求解策略 (General Problem Solving Techniques)
ACPrime
UVa
从第一章开始慢慢刷题,加油!本文来自《算法竞赛入门经典——训练指南》,官方网站:http://code.google.com/p/aoapc-book/UVa特别题库UVa网站专门为本书设立的分类题库配合,方便读者提交:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=442注意,下面注有“e
《算法竞赛入门经典——训练指南》第一章相关内容
weixin_30770495
java数据结构与算法
问题求解策略(GeneralProblemSolvingTechniques)例题(Examples)例题1UVa11292TheDragonofLoowater排序后用贪心法题解例题2UVa11729CommandoWar用贪心法求最优排列;用“相邻交换法”证明正确性题解例题3UVa11300SpreadingTheWealth用代数法进行数学推导;中位数题解例题4LA3708Graveyard
《算法竞赛入门经典——训练指南》第一章算法分类
BEconfidence
UVA训练指南第一章
问题求解策略(GeneralProblemSolvingTechniques)例题(Examples)例题1UVa11292TheDragonofLoowater排序后用贪心法例题2UVa11729CommandoWar用贪心法求最优排列;用“相邻交换法”证明正确性例题3UVa11300SpreadingTheWealth用代数法进行数学推导;中位数例题4LA3708Graveyard推理;参考系
UVA-1374 旋转游戏 题解答案代码 算法竞赛入门经典第二版
漂流瓶jz
算法竞赛入门经典算法aoapc深度优先算法竞赛入门经典图论
GitHub-jzplp/aoapc-UVA-Answer:算法竞赛入门经典例题和习题答案刘汝佳第二版由于书上给了思路,所以做起来并不难。即使超时,因为数据量不大(1000个),我们也可以直接打表直接返回结果。但是如果想不打表完成题目,那么就需要使用思路中给出的各种优化方案,不然很容易超时。我一开始用set作为存储已存在的数字,但还是超时,后面改成用数组存储AC了。AC代码#include#inc
UVA-1343 旋转游戏 题解答案代码 算法竞赛入门经典第二版
漂流瓶jz
算法竞赛入门经典数据结构算法图论aoapc算法竞赛入门经典c++迭代加深搜索
GitHub-jzplp/aoapc-UVA-Answer:算法竞赛入门经典例题和习题答案刘汝佳第二版题目其实不难,但是耗费了我较多时间。这种题关键就是在于找到约束条件,我在DFS的基础上,试了很多种策略:1.对3种数字,每种数字递归遍历一次,这样每次只需要关注一种数字的变化,情况更少。2.使用一个longlong类型的数字作为map的key,key表示这种数字在图形中分别的位置,value表示在
Linux的Initrd机制
被触发
linux
Linux 的 initrd 技术是一个非常普遍使用的机制,linux2.6 内核的 initrd 的文件格式由原来的文件系统镜像文件转变成了 cpio 格式,变化不仅反映在文件格式上, linux 内核对这两种格式的 initrd 的处理有着截然的不同。本文首先介绍了什么是 initrd 技术,然后分别介绍了 Linux2.4 内核和 2.6 内核的 initrd 的处理流程。最后通过对 Lin
maven本地仓库路径修改
bitcarter
maven
默认maven本地仓库路径:C:\Users\Administrator\.m2
修改maven本地仓库路径方法:
1.打开E:\maven\apache-maven-2.2.1\conf\settings.xml
2.找到
 
XSD和XML中的命名空间
darrenzhu
xmlxsdschemanamespace命名空间
http://www.360doc.com/content/12/0418/10/9437165_204585479.shtml
http://blog.csdn.net/wanghuan203/article/details/9203621
http://blog.csdn.net/wanghuan203/article/details/9204337
http://www.cn
Java 求素数运算
周凡杨
java算法素数
网络上对求素数之解数不胜数,我在此总结归纳一下,同时对一些编码,加以改进,效率有成倍热提高。
第一种:
原理: 6N(+-)1法 任何一个自然数,总可以表示成为如下的形式之一: 6N,6N+1,6N+2,6N+3,6N+4,6N+5 (N=0,1,2,…)
java 单例模式
g21121
java
想必单例模式大家都不会陌生,有如下两种方式来实现单例模式:
class Singleton {
private static Singleton instance=new Singleton();
private Singleton(){}
static Singleton getInstance() {
return instance;
}
Linux下Mysql源码安装
510888780
mysql
1.假设已经有mysql-5.6.23-linux-glibc2.5-x86_64.tar.gz
(1)创建mysql的安装目录及数据库存放目录
解压缩下载的源码包,目录结构,特殊指定的目录除外:
32位和64位操作系统
墙头上一根草
32位和64位操作系统
32位和64位操作系统是指:CPU一次处理数据的能力是32位还是64位。现在市场上的CPU一般都是64位的,但是这些CPU并不是真正意义上的64 位CPU,里面依然保留了大部分32位的技术,只是进行了部分64位的改进。32位和64位的区别还涉及了内存的寻址方面,32位系统的最大寻址空间是2 的32次方= 4294967296(bit)= 4(GB)左右,而64位系统的最大寻址空间的寻址空间则达到了
我的spring学习笔记10-轻量级_Spring框架
aijuans
Spring 3
一、问题提问:
→ 请简单介绍一下什么是轻量级?
轻量级(Leightweight)是相对于一些重量级的容器来说的,比如Spring的核心是一个轻量级的容器,Spring的核心包在文件容量上只有不到1M大小,使用Spring核心包所需要的资源也是很少的,您甚至可以在小型设备中使用Spring。
 
mongodb 环境搭建及简单CURD
antlove
WebInstallcurdNoSQLmongo
一 搭建mongodb环境
1. 在mongo官网下载mongodb
2. 在本地创建目录 "D:\Program Files\mongodb-win32-i386-2.6.4\data\db"
3. 运行mongodb服务 [mongod.exe --dbpath "D:\Program Files\mongodb-win32-i386-2.6.4\data\
数据字典和动态视图
百合不是茶
oracle数据字典动态视图系统和对象权限
数据字典(data dictionary)是 Oracle 数据库的一个重要组成部分,这是一组用于记录数据库信息的只读(read-only)表。随着数据库的启动而启动,数据库关闭时数据字典也关闭 数据字典中包含
数据库中所有方案对象(schema object)的定义(包括表,视图,索引,簇,同义词,序列,过程,函数,包,触发器等等)
数据库为一
多线程编程一般规则
bijian1013
javathread多线程java多线程
如果两个工两个以上的线程都修改一个对象,那么把执行修改的方法定义为被同步的,如果对象更新影响到只读方法,那么只读方法也要定义成同步的。
不要滥用同步。如果在一个对象内的不同的方法访问的不是同一个数据,就不要将方法设置为synchronized的。
将文件或目录拷贝到另一个Linux系统的命令scp
bijian1013
linuxunixscp
一.功能说明 scp就是security copy,用于将文件或者目录从一个Linux系统拷贝到另一个Linux系统下。scp传输数据用的是SSH协议,保证了数据传输的安全,其格式如下: scp 远程用户名@IP地址:文件的绝对路径
【持久化框架MyBatis3五】MyBatis3一对多关联查询
bit1129
Mybatis3
以教员和课程为例介绍一对多关联关系,在这里认为一个教员可以叫多门课程,而一门课程只有1个教员教,这种关系在实际中不太常见,通过教员和课程是多对多的关系。
示例数据:
地址表:
CREATE TABLE ADDRESSES
(
ADDR_ID INT(11) NOT NULL AUTO_INCREMENT,
STREET VAR
cookie状态判断引发的查找问题
bitcarter
formcgi
先说一下我们的业务背景:
1.前台将图片和文本通过form表单提交到后台,图片我们都做了base64的编码,并且前台图片进行了压缩
2.form中action是一个cgi服务
3.后台cgi服务同时供PC,H5,APP
4.后台cgi中调用公共的cookie状态判断方法(公共的,大家都用,几年了没有问题)
问题:(折腾两天。。。。)
1.PC端cgi服务正常调用,cookie判断没
通过Nginx,Tomcat访问日志(access log)记录请求耗时
ronin47
一、Nginx通过$upstream_response_time $request_time统计请求和后台服务响应时间
nginx.conf使用配置方式:
log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_r
java-67- n个骰子的点数。 把n个骰子扔在地上,所有骰子朝上一面的点数之和为S。输入n,打印出S的所有可能的值出现的概率。
bylijinnan
java
public class ProbabilityOfDice {
/**
* Q67 n个骰子的点数
* 把n个骰子扔在地上,所有骰子朝上一面的点数之和为S。输入n,打印出S的所有可能的值出现的概率。
* 在以下求解过程中,我们把骰子看作是有序的。
* 例如当n=2时,我们认为(1,2)和(2,1)是两种不同的情况
*/
private stati
看别人的博客,觉得心情很好
Cb123456
博客心情
以为写博客,就是总结,就和日记一样吧,同时也在督促自己。今天看了好长时间博客:
职业规划:
http://www.iteye.com/blogs/subjects/zhiyeguihua
android学习:
1.http://byandby.i
[JWFD开源工作流]尝试用原生代码引擎实现循环反馈拓扑分析
comsci
工作流
我们已经不满足于仅仅跳跃一次,通过对引擎的升级,今天我测试了一下循环反馈模式,大概跑了200圈,引擎报一个溢出错误
在一个流程图的结束节点中嵌入一段方程,每次引擎运行到这个节点的时候,通过实时编译器GM模块,计算这个方程,计算结果与预设值进行比较,符合条件则跳跃到开始节点,继续新一轮拓扑分析,直到遇到
JS常用的事件及方法
cwqcwqmax9
js
事件 描述
onactivate 当对象设置为活动元素时触发。
onafterupdate 当成功更新数据源对象中的关联对象后在数据绑定对象上触发。
onbeforeactivate 对象要被设置为当前元素前立即触发。
onbeforecut 当选中区从文档中删除之前在源对象触发。
onbeforedeactivate 在 activeElement 从当前对象变为父文档其它对象之前立即
正则表达式验证日期格式
dashuaifu
正则表达式IT其它java其它
正则表达式验证日期格式
function isDate(d){
var v = d.match(/^(\d{4})-(\d{1,2})-(\d{1,2})$/i);
if(!v) {
this.focus();
return false;
}
}
<input value="2000-8-8" onblu
Yii CModel.rules() 方法 、validate预定义完整列表、以及说说验证
dcj3sjt126com
yii
public array rules () {return} array 要调用 validate() 时应用的有效性规则。 返回属性的有效性规则。声明验证规则,应重写此方法。 每个规则是数组具有以下结构:array('attribute list', 'validator name', 'on'=>'scenario name', ...validation
UITextAttributeTextColor = deprecated in iOS 7.0
dcj3sjt126com
ios
In this lesson we used the key "UITextAttributeTextColor" to change the color of the UINavigationBar appearance to white. This prompts a warning "first deprecated in iOS 7.0."
Ins
判断一个数是质数的几种方法
EmmaZhao
Mathpython
质数也叫素数,是只能被1和它本身整除的正整数,最小的质数是2,目前发现的最大的质数是p=2^57885161-1【注1】。
判断一个数是质数的最简单的方法如下:
def isPrime1(n):
for i in range(2, n):
if n % i == 0:
return False
return True
但是在上面的方法中有一些冗余的计算,所以
SpringSecurity工作原理小解读
坏我一锅粥
SpringSecurity
SecurityContextPersistenceFilter
ConcurrentSessionFilter
WebAsyncManagerIntegrationFilter
HeaderWriterFilter
CsrfFilter
LogoutFilter
Use
JS实现自适应宽度的Tag切换
ini
JavaScripthtmlWebcsshtml5
效果体验:http://hovertree.com/texiao/js/3.htm
该效果使用纯JavaScript代码,实现TAB页切换效果,TAB标签根据内容自适应宽度,点击TAB标签切换内容页。
HTML文件代码:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
Hbase Rest API : 数据查询
kane_xie
RESThbase
hbase(hadoop)是用java编写的,有些语言(例如python)能够对它提供良好的支持,但也有很多语言使用起来并不是那么方便,比如c#只能通过thrift访问。Rest就能很好的解决这个问题。Hbase的org.apache.hadoop.hbase.rest包提供了rest接口,它内嵌了jetty作为servlet容器。
启动命令:./bin/hbase rest s
JQuery实现鼠标拖动元素移动位置(源码+注释)
明子健
jqueryjs源码拖动鼠标
欢迎讨论指正!
print.html代码:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=Content-Type content="text/html;charset=utf-8">
<title>发票打印</title>
&l
Postgresql 连表更新字段语法 update
qifeifei
PostgreSQL
下面这段sql本来目的是想更新条件下的数据,可是这段sql却更新了整个表的数据。sql如下:
UPDATE tops_visa.visa_order
SET op_audit_abort_pass_date = now()
FROM
tops_visa.visa_order as t1
INNER JOIN tops_visa.visa_visitor as t2
ON t1.
将redis,memcache结合使用的方案?
tcrct
rediscache
公司架构上使用了阿里云的服务,由于阿里的kvstore收费相当高,打算自建,自建后就需要自己维护,所以就有了一个想法,针对kvstore(redis)及ocs(memcache)的特点,想自己开发一个cache层,将需要用到list,set,map等redis方法的继续使用redis来完成,将整条记录放在memcache下,即findbyid,save等时就memcache,其它就对应使用redi
开发中遇到的诡异的bug
wudixiaotie
bug
今天我们服务器组遇到个问题:
我们的服务是从Kafka里面取出数据,然后把offset存储到ssdb中,每个topic和partition都对应ssdb中不同的key,服务启动之后,每次kafka数据更新我们这边收到消息,然后存储之后就发现ssdb的值偶尔是-2,这就奇怪了,最开始我们是在代码中打印存储的日志,发现没什么问题,后来去查看ssdb的日志,才发现里面每次set的时候都会对同一个key