Stockbroker Grapevine - GCC - O(n3)解法

原题

Description

Stockbrokers are known to overreact to rumours. You have been contracted to develop a method of spreading disinformation amongst the stockbrokers to give your employer the tactical edge in the stock market. For maximum effect, you have to spread the rumours in the fastest possible way.

Unfortunately for you, stockbrokers only trust information coming from their "Trusted sources" This means you have to take into account the structure of their contacts when starting a rumour. It takes a certain amount of time for a specific stockbroker to pass the rumour on to each of his colleagues. Your task will be to write a program that tells you which stockbroker to choose as your starting point for the rumour, as well as the time it will take for the rumour to spread throughout the stockbroker community. This duration is measured as the time needed for the last person to receive the information.

Input

Your program will input data for different sets of stockbrokers. Each set starts with a line with the number of stockbrokers. Following this is a line for each stockbroker which contains the number of people who they have contact with, who these people are, and the time taken for them to pass the message to each person. The format of each stockbroker line is as follows: The line starts with the number of contacts (n), followed by n pairs of integers, one pair for each contact. Each pair lists first a number referring to the contact (e.g. a '1' means person number one in the set), followed by the time in minutes taken to pass a message to that person. There are no special punctuation symbols or spacing rules.

Each person is numbered 1 through to the number of stockbrokers. The time taken to pass the message on will be between 1 and 10 minutes (inclusive), and the number of contacts will range between 0 and one less than the number of stockbrokers. The number of stockbrokers will range from 1 to 100. The input is terminated by a set of stockbrokers containing 0 (zero) people.
继续阅读“Stockbroker Grapevine - GCC - O(n3)解法”

RHEL6: NIS的简单配置

参考文档

1. 鸟哥Linux私房菜-NIS http://linux.vbird.org/linux_server/0430nis.php
2. The Linux NIS(YP)/NYS/NIS+ HOWTO http://www.tldp.org/HOWTO/NIS-HOWTO/ypserv.html

实验环境

1. Server1, Server2 系统都是RHEL6.5;
2. Server1 IP为 192.168.122.108;
3. Server2 IP为 192.168.122.50;

实验内容

1. 以Server1 作为 NIS Server, Server2 作为Client.
2. 在Server2上尝试用NIS Server提供的用户信息登录;
3. 配置NFS家目录;


配置NIS Server

1. 安装所需软件包

[root@server1 ~]# yum install yp-tools ypbind ypserv rpcbind

2. 配置Server所属的域和主机名,Server 和 Client要在同一个域里呀。
修改/etc/sysconfig/network

HOSTNAME=server1.nis.example.com
NISDOMAIN=nis.example.com
YPSERV_ARGS="-p 1011"

修改/etc/hosts

192.168.122.108 server1.nis.example.com

继续阅读“RHEL6: NIS的简单配置”

RHEL6: NFS Server 安装与简单配置

参考文档

1. 鸟哥的Linux私房菜-NFS http://linux.vbird.org/linux_server/0330nfs.php
2. Linux NFS-HOWTO http://www.tldp.org/HOWTO/NFS-HOWTO/index.html
3. RFC 1094 https://tools.ietf.org/html/rfc1094
4. Redhat NFS https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/ch-nfs.html

实验环境

1. Server1, Server2 系统均为RHEL6.5;
2. Server1 IP 192.168.122.108;
3. Server2 IP 192.168.122.50;

实验内容

1. 以Server1 作为NFS Server,共享/nfs_pub;用户的udi和gid都使用555.
2. Server2 设置成 NFS Client, 用autofs挂载192.168.122.108:/nfs_pub 到 /nfs/nfs_pub
继续阅读“RHEL6: NFS Server 安装与简单配置”

RHEL7: 救援模式修改root密码

RHEL7的救援模式,相当于RHEL6的单用户模式。
要在不知道root密码的前提下修改root密码,进入救援模式最靠谱。

参考文档

How To Reset Your Forgotten Root Password On CentOS 7 Servers

步骤

1. 进入Grub后修改启动选项。(按e可以编辑)

2. 在linux那一栏,加上

init=/sysroot/bin/sh

3. 删除

rhgb quiet

继续阅读“RHEL7: 救援模式修改root密码”

RHEL6: Postfix的安装与简单配置

Postfix 可用作Mail Server, 它配置起来要比Sendmail简单得多。

参考文档

1. 鸟哥Mail server http://linux.vbird.org/linux_server/0380mail.php
2. Postfix官方文档 http://www.postfix.org/documentation.html
3. 鸟哥DNS server http://linux.vbird.org/linux_server/0350dns.php

实验环境

3台虚拟机,操作系统为CentOS 6.5;
Host1的IP是192.168.56.101, Host2的IP是192.168.56.102,Host2的IP是192.168.56.103;

实验内容

1. Host1与Host2互相收发邮件;
2. 用Telnet发邮件;
3. 邮件Relay;
4. Virtual Alias Domain;
5. Virtual Mailbox Domain;
6. SASL认证;
7. Dovecot.

继续阅读“RHEL6: Postfix的安装与简单配置”

RHEL6: FTP Server - VSFTPD

FTP是最经典的网络服务(之一),就是用来传文件啦。
暑假的时候一同学在Win7上折腾了半天FTP没搞成(估计是防火墙?),而在Linux上整个FTP Server是件很轻松的事情。
推荐使用vsftpd作为FTP server,因为它Very Secure,关键是简单易用。

参考文档

1. 鸟哥Linux私房菜-FTP http://linux.vbird.org/linux_server/0410vsftpd.php
2. vsftpd文档 https://security.appspot.com/vsftpd/vsftpd_conf.html
3. Redhat Document FTP and SELinux https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Managing_Confined_Services/chap-Managing_Confined_Services-File_Transfer_Protocol.html

实验环境

1. Server和Client操作系统均为RHEL6.5;
2. Server机的IP地址是192.168.122.30;
3. Client机的IP地址是192.168.122.92;


安装

在Server端,安装vsftpd.

[root@localhost ~]# yum install vsftpd

在Client端,安装ftp.(还有很多ftp client可以选择~)

[root@main ~]# yum install ftp

继续阅读“RHEL6: FTP Server - VSFTPD”