\(\\\)

\(Description\)


求一个\(N\)个点\(M\)条边的无向图,点度为 \(0\) 的点最多和最少的数量。

  • \(N\le 10^5,M\le \frac {N\times (N-1)}{2}\)

\(\\\)

\(Solution\)


关于最少的数量,注意到一条边会增加两个点度,所以最多能带来 \(2M\) 个点度,最少的零点度点数就是 \(max(N-2M,0)\)。

关于最多的数量,要知道 \(N\) 个点的完全图边数是 \(\frac {N\times (N-1)}{2}\) 。然后就可以二分上界是什么了。

事实上线性扫一下并不会 \(T\) ......

\(\\\)

\(Code\)


#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define N 100010
#define R register
#define gc getchar
using namespace std;
typedef long long ll; inline int rd(){
int x=0; bool f=0; char c=gc();
while(!isdigit(c)){if(c=='-')f=1;c=gc();}
while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=gc();}
return f?-x:x;
} ll n,m,ans,cnt[N]; int main(){
scanf("%lld%lld",&n,&m);
printf("%lld ",max(0ll,n-m*2));
while(m>ans*(ans-1)/2) ++ans;
printf("%lld\n",n-ans);
return 0;
}

[ CodeForces 1065 B ] Vasya and Isolated Vertices的更多相关文章

  1. B. Vasya and Isolated Vertices

    链接 [http://codeforces.com/contest/1065/problem/B] 题意 给你n个点,m条边,让你找最多孤立点和最少孤立点,不能有自环路 分析 对于最少max(0,n- ...

  2. codeforces 676C C. Vasya and String(二分)

    题目链接: C. Vasya and String time limit per test 1 second memory limit per test 256 megabytes input sta ...

  3. Codeforces 1107 E - Vasya and Binary String

    E - Vasya and Binary String 思路:区间dp + 记忆化搜索 转移方程看上一篇博客. 代码: #pragma GCC optimize(2) #pragma GCC opti ...

  4. Codeforces 1076 E - Vasya and a Tree

    E - Vasya and a Tree 思路: dfs动态维护关于深度树状数组 返回时将当前节点的所有操作删除就能保证每次访问这个节点时只进行过根节点到当前节点这条路径上的操作 代码: #pragm ...

  5. Codeforces 1053 B - Vasya and Good Sequences

    B - Vasya and Good Sequences 思路: 满足异或值为0的区间,必须满足一下条件: 1.区间中二进制1的个数和为偶数个; 2.区间二进制1的个数最大值的两倍不超过区间和. 如果 ...

  6. Codeforces 1058 D. Vasya and Triangle(分解因子)

    题目:http://codeforces.com/contest/1058/problem/D 题意:有一个大小为N*M的矩阵内,构造一个三角形,使面积为(n*m)/k.若存在输出三个顶点(整数). ...

  7. codeforces 1041 E.Vasya and Good Sequences(暴力?)

    E. Vasya and Good Sequences time limit per test 2 seconds memory limit per test 256 megabytes input ...

  8. Codeforces 1082 A. Vasya and Book-题意 (Educational Codeforces Round 55 (Rated for Div. 2))

    A. Vasya and Book time limit per test 2 seconds memory limit per test 256 megabytes input standard i ...

  9. Codeforces 837 E Vasya's Function

    Discription Vasya is studying number theory. He has denoted a function f(a, b) such that: f(a, 0) =  ...

随机推荐

  1. windows-nginx安装与运行静态资源

    windows-nginx 官网 http://nginx.org/en/docs/windows.html 点击跳转 安装包下载 http://nginx.org/en/download.html ...

  2. Ubuntu 16.04创建Swap分区或增加Swap分区容量(转)

    要在Ubuntu中要创建Swap分区主要有如下2种方式: 一.传统创建方式 一般情况下,我们都会使用dd命令来预先创建交换分区文件,然后再用/dev/zero将该文件的内容全部置零,创建时还将用到bs ...

  3. Servlet处理日期

    以下内容引用自http://wiki.jikexueyuan.com/project/servlet/handling-date.html: 使用Servlet的最重要的优势之一是可以使用核心Java ...

  4. SqlServer2008发布订阅(数据同步)

    目录 1. 发布必备条件 1.1. 数据库故障还原模型必需为完全还原模型 1.2. 数据库被同步的数据表必须有主键 1.3. 计算机名称来进行SQLServer服务器的注册 1.4. SQLServe ...

  5. 如何使用python书写守护进程?daemon、python-daemon

    可以参考的supervisor实现:https://github.com/Supervisor/supervisor:http://supervisord.org/configuration.html ...

  6. windows 7中添加新硬件的两种方法(本地回环网卡)

    最近在windows7上使用VMwareWorkstation7玩一些实验,遇到需要配置不同网络的问题. 因为在windows2003server上习惯使用要本地回环网卡了,那就想着在Windows7 ...

  7. Windows Update 的工具

    Windows Update MiniTool 是一款管理 Windows Update 的工具,可以取得微軟 Windows 修補程式更新包,Windows Update 是我們用來升級系統的元件, ...

  8. C#如何让Listbox支持多选

    把SelectionMode改成MultiExtended

  9. C# 如何修改Form不能修改窗体大小

    把窗体的FormBorderSytle改一下就可以了,改成FixedSingle或者Fixed3D都可以        

  10. nginx-1.5.10 之mips编译到RT5350

    编译nginx-1.5.10一般须要下面库的支持:pcre,zlib,openssl 此次编译nginx-1.5.10使用的库版本号分别为pcre-8.34:openssl-1.0.0l:zlib-1 ...