D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此
这套题的github地址(里面包含了数据,题解,现场排名):点此
题目描述
Who killed Cock Robin?
I, said the Sparrow, With my bow and arrow,I killed Cock Robin.
Who saw him die?
I, said the Fly.With my little eye,I saw him die.
Who caught his blood?
I, said the Fish,With my little dish,I caught his blood.
Who'll make his shroud?
I, said the Beetle,With my thread and needle,I'll make the shroud.
.........
All the birds of the air
Fell a-sighing and a-sobbing.
When they heard the bell toll.
For poor Cock Robin.
March 26, 2018
Sparrows are a kind of gregarious animals,sometimes the relationship between them can be represented by a tree.
The Sparrow is for trial, at next bird assizes,we should select a connected subgraph from the whole tree of sparrows as trial objects.
Because the relationship between sparrows is too complex, so we want to leave this problem to you. And your task is to calculate how many different ways can we select a connected subgraph from the whole tree.
输入描述:
The first line has a number n to indicate the number of sparrows.
The next n-1 row has two numbers x and y per row, which means there is an undirected edge between x and y.
输出描述:
The output is only one integer, the answer module 10000007 (107+7) in a line
输入例子:
4
1 2
2 3
3 4
输出例子:
10
-->
输入
4
1 2
2 3
3 4
输出
10
说明
For a chain, there are ten different connected subgraphs:
/*
data:2018.04.22
author:gsw
link:https://www.nowcoder.com/acm/contest/104#question
tip:武大校赛--补题
*/
#define IO ios::sync_with_stdio(false);
#define ll long long
#define mod 10000007
#define maxn 200005 #include<iostream>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int dp[maxn];
vector<int> g[maxn];
int a,b,n,ans=;
void init()
{
memset(dp,,sizeof(dp));
} void dfs(int node,int fa)
{
ll t=;
for(int i=;i<g[node].size();i++)
{
if(g[node][i]==fa)continue;
dfs(g[node][i],node);
t=(t+t*dp[g[node][i]])%mod;
}
dp[node]=t;
ans=(ans+t)%mod;
}
int main()
{
init();
scanf("%d",&n);
for(int i=;i<n-;i++)
{
scanf("%d%d",&a,&b);
g[a].push_back(b);g[b].push_back(a);
}
dfs(,);
printf("%d\n",ans);
}
D. Who killed Cock Robin--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)的更多相关文章
- “今日头条杯”首届湖北省大学程序设计竞赛--F. Flower Road
题目链接:点这 github链接:(包含数据和代码,题解):点这 链接:https://www.nowcoder.com/acm/contest/104/E来源:牛客网 题目描述 (受限于评测机,此题 ...
- “今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛 )--E. DoveCCL and Resistance
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/D来源:牛客网 题目描述 ...
- A. Srdce and Triangle--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
如下图这是“今日头条杯”首届湖北省大学程序设计竞赛的第一题,作为赛后补题 题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 Let be a regualr tr ...
- I. Five Day Couple--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 链接:https://www.nowcoder.com/acm/contest/104/H来源:牛客网 题目描述 ...
- H. GSS and Simple Math Problem--“今日头条杯”首届湖北省大学程序设计竞赛(网络同步赛)
题目描述:链接点此 这套题的github地址(里面包含了数据,题解,现场排名):点此 题目描述 Given n positive integers , your task is to calculat ...
- “东信杯”广西大学第一届程序设计竞赛(同步赛)H
链接:https://ac.nowcoder.com/acm/contest/283/H来源:牛客网 题目描述 由于临近广西大学建校90周年校庆,西大开始了喜闻乐见的校园修缮工程! 然后问题出现了,西 ...
- D. Who killed Cock Robin 湖北省大学程序设计竞赛
链接:https://www.nowcoder.com/acm/contest/104/C来源:牛客网 The Sparrow is for trial, at next bird assizes,w ...
- 2019年广东工业大学腾讯杯新生程序设计竞赛(同步赛)E-缺席的神官
链接:https://ac.nowcoder.com/acm/contest/3036/E 来源:牛客网 题目描述 面前的巨汉,让我想起了多年前的那次,但这个巨汉身上散布着让人畏惧害怕的黑雾.即使看不 ...
- 牛客竞赛-Who killed Cock Robin
Who killed Cock Robin? I, said the Sparrow, With my bow and arrow,I killed Cock Robin. Who saw him d ...
随机推荐
- SCP-bzoj-1069
项目编号:bzoj-1069 项目等级:Safe 项目描述: 戳这里 特殊收容措施: 求凸包后在凸包上旋转卡壳.然而复杂度要求较低,故可直接枚举四边形的一条对角线,另两个顶点在凸包上随这条对角线的移动 ...
- jmeter 基础介绍
Apache JMeter是Apache组织开发的基于Java的压力测试工具.用于对软件做压力测试,它最初被设计用于Web应用测试,但后来扩展到其他测试领域.它可以用于对静态的和动态的资源(文件,Se ...
- BZOJ 4555(第二类斯特林数+NTT)
传送门 解题思路 数学题,推式子.求\(f(n)=\sum\limits_{i=0}^n\sum\limits_{j=0}^iS(i,j)2^jj!\) 首先可以把\(j\)往前提: \[f(n)=\ ...
- AcWing 224. 计算器 (BSGS算法)打卡
题目:https://www.acwing.com/problem/content/226/ 题意:有一个计算器能完成三种功能 1.给定Y,Z,P,计算YZModPYZModP 的值: 2.给定Y,Z ...
- php-fpm.conf详细解析篇
一:php-fpm.conf详细解析篇: pm = static (静态模式)时只需修改 max_children数值 pm = dynamic (动态模式)时只需修改其它三个数值 pm.max_ch ...
- 【Shiro】五、Apache Shiro加密
Shiro提供了更好封装,更好使用的加密算法API,可以作为平时使用的一个工具类的预选方案. Shiro的密码学 基本特性 接口驱动,基于POJO 对JCE(Java Cryptography Ext ...
- Python3中 if __name__=='__main__'是个什么意思
在python前期学习中或者在学flask中,if_name_ = ="_main_"经常出现在我们的眼帘中,我们经常会问,这个是个什么玩意儿,它是干什么的? 我们知道,if 语句 ...
- eclipse 中的.classpath和.project文件的具体作用(转)
转载博客:http://www.cnblogs.com/panjun-Donet/archive/2010/08/25/1807780.html .project是项目文件,项目的结构都在其中定义,比 ...
- Name your feature branches by convention
https://docs.microsoft.com/en-us/azure/devops/repos/git/git-branching-guidance?view=azure-devops Nam ...
- JdbcTemplate 的oracle分页
@Autowired private JdbcTemplate jd; int ps1=Integer.valueOf(pageSize); int cp1=Integer.valueOf(currP ...