现在位置: 首页 > junkyard发表的所有文章
  • 07月
  • 25日
综合 ⁄ 共 474字 评论关闭
Rotate Image You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). Follow up: Could you do this in-place? 思路: 可以参见Programming Pearls,很多时候旋转是可以用reverse代替的。 做顺时针90度旋转,可以先转置矩阵,然后对矩阵的每一行进行reverse。 题解: class Solution { public: void rotate(vector<vector<int> > &matrix) { const size_t N = matrix.size(); // transpose first for(size_t i = 0; i < N; +......
阅读全文
  • 02月
  • 22日
综合 ⁄ 共 1969字 评论关闭
题目链接~~> 做题感悟:这题是在还没去西安比赛的时候做的练习赛,做时是学长想的思路,感觉自己弱爆了,这题想法确实挺好。 解题思路:                 猛的一看貌似很难的样子,但是只要细心一点你就会找到突破口,因为每个数最多开方 63 次 ,这样我们可以每次更新区间的时候直接暴力到叶子节点,但是只这样是不行的,还要用一个标记,记录整个区间是否还需要开方。注意:开方的时候开方的数要乘以1.0 ,题目给的区间不一定是 x < y ,需要判断一下。 代码: #pragma comment(linker, "/STACK:1024000000,1024000000") #......
阅读全文
  • 10月
  • 10日
综合 ⁄ 共 75字 评论关闭
http://note.youdao.com/share/?id=785dc0f2d9cfba675ea9d81fe1f9370c&type=note
阅读全文
  • 07月
  • 16日
综合 ⁄ 共 658字 评论关闭
今天看到偶然间看到一篇blog,“用NSZombieEnabled解决恼人的EXC_BAD_ACCESS错误”。 很实用的技巧,便拿来试验一下。 原文是在XCode3里面设置的,so在4里面完全找不到地方。stackoverflow搜一下,找到如下方法。 菜单里Product->EditScheme->Run->Environment Variables, 添加NSZombieEnabled,YES。 顺便发现方法2,Product->按住alt/option+鼠标点"Run...",之后同上。 如果你和我一样操作了,一定发现了:按下alt/option键之后菜单边了,同理,按下Ctrl键之后菜单也变了。 神奇ing! 顺便在Navigate看到一......
阅读全文
  • 07月
  • 07日
综合 ⁄ 共 2746字 评论关闭
一、spring中context:property-placeholder元素    1.有些参数在某些阶段中是常量                 a、在开发阶段我们连接数据库时的连接url,username,password,driverClass等                 b、分布式应用中client端访问server端所用的server地址,port,service等                   c、配置文件的位置    2.而这些参数在不同阶段之间又往往需要改变                在项目开发阶段和交付阶段数据库的连接信息往往是不同的,分布式应用也是同样的情况。 期望:能不能有一种解决方案可以方便我们在一个阶段内不需要频繁书......
阅读全文
  • 06月
  • 06日
综合 ⁄ 共 14352字 评论关闭
    对于嵌入式设备几个关键对象:屏幕光标键盘 QShared|---QGLayoutIterator|          |---QLayoutArrayIterator|          |---QBoxLayoutIterator|          |---QToolLayoutIterator|          |---QMainWindowLayoutIterator|---QBrushData|---QDOM_ImplementationPrivate|---QDOM_NodePrivate|           |---QDOM_DocumentTypePrivate|           |---QDOM_DocumentFragmentPrivate|           |---QDOM_CharacterDataPrivate|           |                |---QDOM_TextPrivate|           |                |      ......
阅读全文
  • 04月
  • 25日
综合 ⁄ 共 1758字 评论关闭
题意:有n(n<=100)个点的树,每个点有固定的val值,走每条边需要花费固定的时间,问Hu Bayi能否从1在给定的时间范围内走到n(n点为出口),          如果不能输出"Human beings die in pursuit of wealth, and birds die in pursuit of food!",如果能输出在所经过的路径上能得到的最大val和。 题解:树形dp,首先DFS得出从1->n路径上的权值和tot,并将路径上的权值置0,这样能够保证从1->n的路径始终是通的,然后进行树形dp+01背包即可。 Sure原创,转载请注明出处。 #include <iostream> #include <cstdio&......
阅读全文
  • 04月
  • 19日
综合 ⁄ 共 463字 评论关闭
默认安装的RubyGems包之后,其中只包括RubyForge的源,因此你会错过很多很好的gems。要加入更多的rubygems源,方法很简单: gem sources -a http://path.to.gem.repository/ 你可以使用下面的命令添加GitHub的源: gem sources -a http://gems.github.com/ 要查看当前已经使用的gems源可以这样: gem sources 要删除某个源可以这样: gem sources -r http://path.to.gem.repository/ 因为GitHub的Gems服务已经标识为过期,因此,你可以选择其他的Gems源。其中一个值得推荐的地方是:GemCutter。不过GemCutter的源的添......
阅读全文
  • 01月
  • 28日
综合 ⁄ 共 1236字 评论关闭
linux 下查看机器是cpu是几核的 几个cpu more /proc/cpuinfo |grep "physical id"|uniq|wc -l 每个cpu是几核(假设cpu配置相同) more /proc/cpuinfo |grep "physical id"|grep "0"|wc -l cat /proc/cpuinfo | grep processor 1. 查看物理CPU的个数 #cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l   2. 查看逻辑CPU的个数 #cat /proc/cpuinfo |grep "processor"|wc -l   3. 查看CPU是几核 #cat /proc/cpuinfo |grep "cores"|uniq   4. 查看CPU的主频 #cat /proc/cpuinfo |grep MHz|uniq   # uname -a Linux euis1 2.6......
阅读全文
  • 01月
  • 28日
综合 ⁄ 共 1051字 评论关闭
#!/usr/bin/env python # -*- coding=utf-8 -*- #Using GPL v2.7 #Author: leexide@126.com #Python监控网卡流量 """ 1、实现原理:通过SNMP协议获取系统信息,再进行相应的计算和格式化,最后输出结果 2、特别注意:被监控的机器上需要支持snmp。yum install -y net-snmp*安装 """ #!/usr/bin/python import re import os #get SNMP-MIB2 of the devices def getAllitems(host,oid): sn1 = os.popen('snmpwalk -v 2c -c public ' + host + ' ' + oid).read().split('\n')[:-1] return sn1 ......
阅读全文
  • 01月
  • 23日
综合 ⁄ 共 2794字 评论关闭
在Java中可以基于Socket,ServerSocket来实现TCP/IP+BIO的系统间通信。Socket主要用于实现建立连接及网络IO的操作,ServerSocket主要用于实现服务器端端口的监听及Socket对象的获取。 Socket实现客户端的关键代码如下: /*创建连接,如果域名解析不了会抛出UnkownHostException,当连接不上时会抛出IOException。        *如果希望控制建立连接的超时,可先调用socket=newSocket(),然后调用socket.connect(SocketAddress endpoint, int timeout) 方法        */        Socket socket = new Socket("www.baidu.com", 80);        /......
阅读全文
  • 01月
  • 19日
综合 ⁄ 共 1030字 评论关闭
Problem of Precision Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 948    Accepted Submission(s): 554 Problem Description   Input The first line of input gives the number of cases, T. T test cases follow, each on a separate line. Each test case contains one positive integer n. (1 <= n <= 10^9) Output For each input case, you should output the answer in one line. Sample Input 3 1 2 5   Sample Output 9 97 841 /* HDU 2......
阅读全文