-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[package] | ||
name = "e200-server-broadcast" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
1 0 0 | ||
0 1 0 | ||
0 0 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 1 | ||
1 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# 服务器广播/需要广播的服务器数量 | ||
|
||
## 题目描述 | ||
|
||
服务器连接方式包括直接相连, 间接连接. | ||
|
||
A和B直接连接, B和C直接连接, 则A和C间接连接. | ||
|
||
直接连接和间接连接都可以发送广播. | ||
|
||
给出一个N*N数组, 代表N个服务器. | ||
|
||
matrix[i][j] == 1, 则代表i和j直接连接; 不等于 1 时, 代表i和j不直接连接. | ||
|
||
matrix[i][i] == 1, 即自己和自己直接连接. matrix[i][j] == matrix[j][i]. | ||
|
||
计算初始需要给几台服务器广播, 才可以使每个服务器都收到广播. | ||
|
||
### 输入描述 | ||
|
||
输入为N行, 每行有N个数字, 为0或1, 由空格分隔, | ||
|
||
构成N*N的数组, N的范围为 1 <= N <= 40. | ||
|
||
### 输出描述 | ||
|
||
输出一个数字, 为需要广播的服务器的数量. | ||
|
||
### 示例1 | ||
|
||
输入: | ||
|
||
```text | ||
{{#include assets/input1.txt}} | ||
``` | ||
|
||
输出: | ||
|
||
```text | ||
{{#include assets/output1.txt}} | ||
``` | ||
|
||
说明: 3 台服务器互不连接, 所以需要分别广播这 3 台服务器. | ||
|
||
### 示例2 | ||
|
||
输入: | ||
|
||
```text | ||
{{#include assets/input2.txt}} | ||
``` | ||
|
||
输出: | ||
|
||
```text | ||
{{#include assets/output2.txt}} | ||
``` | ||
|
||
说明: 2 台服务器相互连接, 所以只需要广播其中一台服务器. | ||
|
||
## 题解 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} |