欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Educational Codeforces Round 52 (Rated for Div. 2) B. Vasya and Isolated Vertices

程序员文章站 2022-05-09 17:37:58
...

题目链接:http://codeforces.com/contest/1065/problem/B
思路:n个点两两连接最多连n*(n-1)/2条边,最少连n-2*m,
c++代码:

#include <iostream>

using namespace std;

typedef long long LL;


int main() {
    LL n,m;
	cin >> n >> m;
	 if(m>0){
		LL t1=n-2*m;
		if(t1<0)t1=0;
		LL t=0;
		cout <<t1 <<" " ;
		//if(m>0&&n>0)
		for(t;t<=n;t++) {
			if(t*(t-1)/2>=m) {
				cout <<n-(t) <<endl;
				break;
			}
		}
		//cout <<n <<endl;
	}	
	else cout << n<<" "<<n<<endl;
	
	
	return 0;
}