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;
}
推荐阅读
-
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(前缀和,思维)