Http://codeforces.com/contest/1065/problem/B
Problem
Given q \ (n\) and \ (m\), ask \ (n\) points \ (m\) edges with no re-edges and self-loops with the largest and least number of orphaned points.
Exercises
At the very least, you can maximize the use of the edge by two or two connected.
Most of the words can be a bunch of points as far as possible to the full picture, the rest are isolated points.
#include <bits/stdc++.h>#ifdef LOCAL #define debug(...) fprintf(stderr, __VA_ARGS__)#else #define debug(...) 0#endifusing namespace std;typedef long long ll;typedef unsigned int uint;typedef unsigned long long ull;typedef pair<int, int> pii;int rint() { int n, c, sgn = 0; while ((c = getchar()) < ‘-‘); if (c == ‘-‘) n = 0, sgn = 1; else n = c - ‘0‘; while ((c = getchar()) >= ‘0‘) { n = 10 * n + c - ‘0‘; } return sgn ? -n : n;}int main() { ll n, m; // f**k myself scanf("%lld %lld", &n, &m); if (m == 0) { printf("%lld %lld\n", n, n); return 0; } if (n == 1) { puts("1 1"); return 0; } ll mi = (2 * m >= n ? 0 : n - 2 * m); ll ma = 2; while (ma < n && ma * (ma - 1) < 2 * m) ma++; assert(ma >= 2); ma = n - ma; printf("%lld %lld\n", mi, ma); return 0;}
Summarize
It was long long
wrong two times without driving ... Don't know what to say, don't be so fascinated in the future.
Educational Codeforces Round #52 b. Vasya and Isolated Vertices