Codeforces Round #506 (Div. 3) E
Codeforces Round #506 (Div. 3) E
dfs+贪心
#include<bits/stdc++.h> using namespace std;
typedef long long ll;
const int maxn = ;
int n,u,v;
int ans;
vector<int>M[maxn];
int dfs(int cur,int pre)
{
int ret = ;
for(int i=;i<M[cur].size();i++)
{
int nex = M[cur][i];
if(pre == nex)continue;
ret = min(ret,dfs(nex,cur));
}
if(ret == && cur != && pre != )ans++;
return (ret+)%;
}
int main()
{
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d",&u,&v);
M[u].push_back(v);
M[v].push_back(u);
}
dfs(,);
cout<<ans<<endl;
}
Codeforces Round #506 (Div. 3) E的更多相关文章
- Codeforces Round #506 (Div. 3) 题解
Codeforces Round #506 (Div. 3) 题目总链接:https://codeforces.com/contest/1029 A. Many Equal Substrings 题意 ...
- Codeforces Round #506 (Div. 3) D-F
Codeforces Round #506 (Div. 3) (中等难度) 自己的做题速度大概只尝试了D题,不过TLE D. Concatenated Multiples 题意 数组a[],长度n,给 ...
- Codeforces Round #506 (Div. 3)
题解: div3水的没有什么意思 abc就不说了 d题比较显然的就是用hash 但是不能直接搞 所以我们要枚举他后面那个数的位数 然后用map判断就可以了 刚开始没搞清楚数据范围写了快速乘竟然被hac ...
- Codeforces Round #506 (Div. 3) D. Concatenated Multiples
D. Concatenated Multiples You are given an array aa, consisting of nn positive integers. Let's call ...
- Codeforces Round #506 (Div. 3) C. Maximal Intersection
C. Maximal Intersection time limit per test 3 seconds memory limit per test 256 megabytes input stan ...
- Codeforces Round #506 (Div. 3) - D. Concatenated Multiples(思维拼接求是否为k的倍数)
题意 给你N个数字和一个K,问一共有几种拼接数字的方式使得到的数字是K的倍数,拼接:“234”和“123”拼接得到“234123” 分析: N <= 2e5,简单的暴力O(N^2)枚举肯定超时 ...
- 【Codeforces Round #506 (Div. 3) 】
A:https://www.cnblogs.com/myx12345/p/9844334.html B:https://www.cnblogs.com/myx12345/p/9844368.html ...
- Codeforces Round #506 (Div. 3)B.Creating the Contest(dp)
B. Creating the Contest time limit per test 1 second memory limit per test 256 megabytes input stand ...
- Codeforces Round #506 (Div. 3) A-C
CF比赛题解(简单题) 简单题是指自己在比赛期间做出来了 A. Many Equal Substrings 题意 给个字符串t,构造一个字符串s,使得s中t出现k次;s的长度最短 如t="c ...
随机推荐
- 【SD系列】SAP 跨年时更改销售凭证号码段
公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[SD系列]SAP 跨年时更改销售凭证号码段 ...
- Fitness初接触
http://www.fitnesse.org/FitNesseDownload 1. Click on the most recent fitnesse-standalone.jar file an ...
- 1、Laravel 环境配置及安装
一.开发工具及环境 PHPStorm + phpStudy 最新版 Composer 安装 https://www.phpcomposer.com/ 下载就可以,设置中国镜像 安装完成后 compos ...
- JavaScript 高级程序设计(第3版)第二章 (在html中使用js)
1.script元素的属性(6个):①async(异步脚本),只对外部脚本有效 ②defer(延迟脚本),只对外部脚本有效 ③charset,src(可跨域),type,language 2.尽可能使 ...
- 自定义Aspect风格的AOP框架
本篇博客参考<架构探险--从零开始写java web框架>4.3章节 1代理接口: package smart.myaop.framework; public interface Prox ...
- Mysql 在 select 查询时追加(添加)一个字段并指定值
在特定时候,在 mysql 的查询结果中我们需要追加一个字段来实现某些特定的功能,这时我们可以用到以下语法来实现 值 as 字段比如我们需要给这个查询结果追加一个 xx 字段并赋值为 null ,可以 ...
- [Codeforces 865C]Gotta Go Fast(期望dp+二分答案)
[Codeforces 865C]Gotta Go Fast(期望dp+二分答案) 题面 一个游戏一共有n个关卡,对于第i关,用a[i]时间通过的概率为p[i],用b[i]通过的时间为1-p[i],每 ...
- mySql配置在nodejs中使用
mySql安装完成后,配置链接nodejs项目中的数据库. 1.测试是否安装成功. 2.use nodejs使用nodejs 3.设置数据源 5.exit
- redis学习(二)
简单了解一下 1.build.gradle中添加 依赖 org.springframework.boot:spring-boot-starter-data-redis //定义依赖:声明项目中需要哪 ...
- shell截取小数点前后的子串