[河南省ACM省赛-第三届] 网络的可靠性 (nyoj 170)
2015-04-02 08:46
369 查看
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=170
根据题意,需要找到度数为1的结点个数,如下图:
根据题意,需要找到度数为1的结点个数,如下图:
#include<iostream> #include<cstdio> #include<cstring> #include<vector> using namespace std; #define N 10002 vector<int> g ; int main() { freopen("d:\\in.txt", "r", stdin); int n; while(~scanf("%d", &n)) { int a, b; for(int i=0; i<n+2; i++){ g[i].clear(); } for(int i=0; i<n-1; i++){ scanf("%d%d", &a, &b); g[a].push_back(b); g[b].push_back(a); } int tot = 0;//度为1的个数 for(int i=1; i<=n; i++){ if(g[i].size() == 1) tot++; } printf("%d\n", (tot+1)/2); } }
相关文章推荐
- nyoj 170 网络的可靠性 第三届河南省赛
- nyoj170 网络的可靠性(第三届河南省程序设计大赛)
- 第三届河南省程序设计大赛-NYOJ-170-网络的可靠性
- NYOJ-170-网络的可靠性(第三届河南省程序设计大赛C题(思维题))
- [河南省ACM省赛-第三届] 房间安排 (nyoj 168)
- [河南省ACM省赛-第三届] 素数 (nyoj 169)
- [河南省ACM省赛-第三届] 聪明的kk (nyoj 171)
- [河南省ACM省赛-第三届] AMAZING AUCTION (nyoj 251)
- [河南省ACM省赛-第三届] BUYING FEED (nyoj 248)
- nyoj1277 Decimal integer conversion (河南省acm第九届省赛)
- nyoj 170 网络的可靠性
- nyoj--170--网络的可靠性(水题)
- nyoj 1242 Interference Signal 河南省ACM2015年省赛G题
- [河南省ACM省赛-第五届] 试制品 (nyoj 542)
- NYOJ 170 网络的可靠性
- NYOJ 170 网络的可靠性
- nyoj--170--网络的可靠性(水题)
- 第三届省赛 网络的可靠性
- [河南省ACM省赛-第四届] 走迷宫 (nyoj 306)
- nyoj 16 矩形嵌套&&第七届河南省acm省赛H题