http://poj.org/problem?id=3687
非常坑的一道题,最后快要绕晕了。。
题意:有N个球,重量分别是1~N,给着n个球贴上标签。输入n,m代表n个球和m条边(a b),代表 标签为a的要比标签为b的轻。最后输出标签1~N对应的重量(注意是重量,而不是轻重关系),还有要注意“ you should output the one with the smallest
we...
分类:
其他 时间:
2014-03-27 01:25:49
收藏:
0 评论:
0 赞:
0 阅读:
483
题目
Implement pow(x, n).
分析
分治法(解法1)和一种比较巧的方法(解法2)
解法1
public class Pow {
public double pow(double x, int n) {
if (n == 0) {
return 1;
} else if (n > 0) {
if (n == 1) {
return x;
...
分类:
其他 时间:
2014-03-27 00:54:30
收藏:
0 评论:
0 赞:
0 阅读:
336
题目
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?
分析
这题就是想清楚移动时索引值得变化关系即可。还要注意一轮移动涉及四个元素,因此只要遍...
分类:
其他 时间:
2014-03-27 01:02:43
收藏:
0 评论:
0 赞:
0 阅读:
482
C++虚拟多重继承对象模型讨论
作者:magictong
调试环境:Windows7VS2005
概述
记得刚开始写C++程序时,那还是大学时光,感觉这玩意比C强大多了,怎么就实现了多态,RTTI这些牛逼的玩意呢?当时没有深究,后来零零散散看过一些介绍的文章,也看了一些相关的书籍,总觉得说得不甚清楚。而这些问题的本质还是在于C++对象的内存模型问题,数据结构决定了你的算法...
分类:
编程语言 时间:
2014-03-27 01:04:17
收藏:
0 评论:
0 赞:
0 阅读:
515
A - LIGHTOJ 1005
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Submit Status
Description
A rook is a piece used in the game of chess which is played on a board...
分类:
其他 时间:
2014-03-27 00:22:40
收藏:
0 评论:
0 赞:
0 阅读:
564
/* This retransmits one SKB. Policy decisions and retransmit queue
* state updates are done by the caller. Returns non-zero if an
* error occurred which prevented the send.
*/
int tcp_retransmit_...
分类:
系统服务 时间:
2014-03-27 01:25:15
收藏:
0 评论:
0 赞:
0 阅读:
542
1. 概述
为了进一步分析recovery系统使用资源png文件的过程,我们把相关代码剥离出来,作成小例子进行分析。
2. 正向分析的代码
这个小例子的第一步是能够遍历出png中所有locale的图片信息。
2.1 代码
代码如下:
/*
* gcc png_example.c -Iinclude -lpng
*
* The original code...
分类:
其他 时间:
2014-03-27 00:55:29
收藏:
0 评论:
0 赞:
0 阅读:
416
当知道需要重传数据结的时候执行这个函数:
对于函数tcp_xmit_retransmit_queue:需要重传哪些包呢到底?
首先是lost、标记的包;
然后还需要处理:之前发送过的但是尚未收到确认的包(向前重传),或者新数据,在这两者之间有一个选择
/* This gets called after a retransmit timeout, and the initially
...
分类:
系统服务 时间:
2014-03-27 00:44:12
收藏:
0 评论:
0 赞:
0 阅读:
700
这里主要说的是TCP拥塞情况下的状态状态处理
/* Process an event, which can update packets-in-flight not trivially.
* Main goal of this function is to calculate new estimate for left_out,
* taking into account both pa...
分类:
系统服务 时间:
2014-03-27 00:35:27
收藏:
0 评论:
0 赞:
0 阅读:
963
题目
Given an array of strings, return all groups of strings that are anagrams.
Note: All inputs will be in lower-case.
分析
对字符串中各字母进行排序,那么互为重排列的字符串就会相等。
按照上述思路,用一个map纪录按字母排序后的字符串及其出现位置(或原字符串)...
分类:
其他 时间:
2014-03-27 00:23:41
收藏:
0 评论:
0 赞:
0 阅读:
633
题目:输入两个递增排序的链表,合并这两个链表并使新链表中的节点仍然是按照递增排序的。
要求:
1、输入的两个链表中有一个或者多个元素相等。
2、输入的链表中有一个或者两个链表都是空链表。
基本思路:
相信大家都知道这题的思路,本题的考点并在在于思路,而在于对链表基本性质的掌握程序,对链表的创建,构造,重置等性质有了一定的了解,求解本题并不难。
对于两个链表,分别有指针指着两个链...
分类:
其他 时间:
2014-03-27 00:54:00
收藏:
0 评论:
0 赞:
0 阅读:
459
题目
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other.
Given an integer n, return all distinct solutions to the n-queens ...
分类:
其他 时间:
2014-03-27 01:26:22
收藏:
0 评论:
0 赞:
0 阅读:
451
题目
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
分析
所有结果都能列出来,那么个数当然能数出来,思路和N-Queens中一致,不再赘述。这里给出一种比较凶残的解法:...
分类:
其他 时间:
2014-03-27 01:14:59
收藏:
0 评论:
0 赞:
0 阅读:
480
为了测试多个DK分布键情况下,多表关联是否可以镜像segment过滤,测试如下:
[gpadmin@gtlions50 ~]$ psql gtlions
psql (8.2.15)
Type "help" for help.
gtlions=# create table gtt1(id int,name character varying(5)) distributed by (i...
分类:
其他 时间:
2014-03-27 01:16:31
收藏:
0 评论:
0 赞:
0 阅读:
497
0. Oracle测试数据准备:
[oracle@db1 ~]$ sqlplus system/000000
SQL*Plus: Release 11.2.0.3.0 Production on Tue Mar 25 10:26:06 2014
Copyright (c) 1982, 2011, Oracle. All rights reserved.
C...
分类:
数据库技术 时间:
2014-03-27 00:35:01
收藏:
0 评论:
0 赞:
0 阅读:
714
在VC中,经常要用到整型与字符串之间的来回转换,此处记录,以便以后查看。
1 整型转换为字符串类型。
第一种方法:利用CString对象的Format函数。
int flag;
CString csflag;
flag = 10;
csflag.Format("%d",flag);
MessageBox(csflag);
第二种方法:使用itoa函数。
int fla...
分类:
其他 时间:
2014-03-27 01:03:14
收藏:
0 评论:
0 赞:
0 阅读:
1168
prim算法:
#include
#include
#include
#define MAX 0x7fffffff
using namespace std;
int dis[200][200],vis[200],low[200],n,m;
int prim()
{
int i,j,sum=0,pos=1;
memset(vis,0,sizeof(vis));
vis...
分类:
其他 时间:
2014-03-27 00:53:28
收藏:
0 评论:
0 赞:
0 阅读:
489
muduo库中的源码并不是很多,但是回调的处理非常巧妙,这里从事件激活(某个套接字上可读/可写)以后这个层次看回调怎么被调用的。
首先从最大的EventLoop说起:
EventLoop中拥有事件链表(每一个元素都是Channel),在loop函数中调用epoll_wait系统调用的时候,将EpollPollr中EventList,将这个链表中激活事件添加到EventLoop中...
分类:
其他 时间:
2014-03-27 01:23:14
收藏:
0 评论:
0 赞:
0 阅读:
489
首先看TcpServer:
在这里肯定是有socketfd的,不然这个监听套接字是怎么被关注的呢!这样的操作时通过Accept来处理的
Acceptor:
在这个类就是提供给TcpServer让其监听的,类中有Channel,也有一个Socket,有一个事件handleRead(),这个函数肯定是提供给Channel的,等到Acceptor中的socketfd...
分类:
其他 时间:
2014-03-27 01:10:51
收藏:
0 评论:
0 赞:
0 阅读:
439
1删除ocr盘,vote盘,数据盘
(1)备份数据库之后,停止数据库,使用dbca删除数据库
(2)移除diskgroup
进入节点2:export
ORACLE_SID=+ASM2
sqlplus/ as sysdba
Alter diskgroup dgdata dismount;
...
分类:
数据库技术 时间:
2014-03-27 01:07:24
收藏:
0 评论:
0 赞:
0 阅读:
743