【題意】輸入k,為乙個父伺服器最多同時傳給幾個兒子伺服器。以及row 為剩餘幾行輸入。接下來row行,每行第乙個數number代表這一行需要輸入的數,接下來的乙個數代表父節點,這一行剩下的都是這個父節點的子兒子。伺服器可並行傳輸,問至少要傳幾次才能傳輸完成。
【輸入輸出】
輸入 1 2 (k=1 剩餘2行)
3 0 1 2(代表0是父節點 1 2是他的子節點)
2 1 3(1是父節點,3是他的子節點)
輸出 2
【思路】
構建vector,取名open_list,也就是已經被傳輸的伺服器,只要open_list的size不等於所有伺服器的數目,就要傳播資料。每次取open_list的所有點,遍歷它未被傳輸的子兒子(注意k的限制),遍歷到這個兒子,就把這個兒子刪除,把它加入open_list (也就是兒子也變成了其他兒子的父親 來進行遍歷)
【**】
#include#include#include#include#include#includeusing namespace std;
#define maxi 0x3f3f3f3f;
std::vectoropen_list;
std::vectorv[1000000];
int k,row,n;
int tree[1000000];
int findroot(int x)
}int main(int argc, char const *ar**)
} int root;
for(int i=0;i<=n;i++)
open_list.push_back(root);
int totalcount=n+1,temp_k;
int output=0,bound;
while(open_list.size()!=totalcount)
}} cout
}
伺服器sendfile傳輸檔案
在apache,nginx,lighttpd等web伺服器當中,都有一項sendfile相關的配置,在一些網上的資料都有談到sendfile會提公升檔案傳輸效能,那sendfile到底是什麼呢?它的原理又是如何呢?在傳統的檔案傳輸裡面 read write方式 在實現上其實是比較複雜的,需要經過多次...
伺服器檔案傳輸
scp r 在本地向伺服器傳輸檔案 從本地上傳檔案到伺服器,終端命令應執行在本機上 scp 本地檔案的路徑 伺服器使用者名稱 伺服器位址 伺服器上存放檔案的路徑 scp scp1.png root 119.23.75.150 home admin scp r 本地資料夾的路徑 伺服器使用者名稱 伺服...
伺服器間檔案傳輸
單傳檔案 scp home tmp 1.txt username 192.127.124.123 home test 傳資料夾 包括資料夾本身 scp r home tmp username 192.127.124.123 home test 傳資料夾下的所有檔案 不包含資料夾本身 scp home...