Educational Codeforces Round 52 (Rated for Div. 2) B. Vasya and Isolated Vertices
程序员文章站
2022-05-09 17:38:04
...
题解
题目大意 给你n个点使用m条边组成一个图 问你最多和最小能有多少个孤立节点(度为0)
最少的点个数就是每个边连两个点m-n2和0取max
最多的点计算d(d-1)=m*2用n-d 需要特判0
AC代码
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
#ifdef LOCAL
//freopen("C:/input.txt", "r", stdin);
#endif
ll n, m;
cin >> n >> m;
ll d;
for (d = 0; d * (d + 1) <= m * 2; d++);
cout << max(0LL, n - m * 2) << " " << n - d - 1 + (d * (d - 1) == m * 2) + (m == 0) << endl;
return 0;
}
上一篇: Educational Codeforces Round 52 (Rated for Div. 2)B. Vasya and Isolated Vertices
下一篇: Educational Codeforces Round 52 (Rated for Div. 2) A. Vasya and Chocolate
推荐阅读
-
Educational Codeforces Round 49 (Rated for Div. 2) B. Numbers on the Chessboard
-
Educational Codeforces Round 49 (Rated for Div. 2) B. Numbers on the Chessboard
-
B. RPG Protagonist[Educational Codeforces Round 94 (Rated for Div. 2)]数学枚举
-
Educational Codeforces Round 52 (Rated for Div. 2)B. Vasya and Isolated Vertices
-
Educational Codeforces Round 52 (Rated for Div. 2) B. Vasya and Isolated Vertices
-
Educational Codeforces Round 52 (Rated for Div. 2) A. Vasya and Chocolate
-
Educational Codeforces Round 48 (Rated for Div. 2) C. Vasya And The Mushrooms(思维)
-
Educational Codeforces Round 53 (Rated for Div. 2) B. Vasya and Books
-
Educational Codeforces Round 52 (Rated for Div. 2) B. Vasya and Isolated Vertices
-
Educational Codeforces Round 50 (Rated for Div. 2) D. Vasya and Arrays(前缀和,思维)