Educational Codeforces Round #52 b. Vasya and Isolated Vertices

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.