题目链接: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;
}