Fzu 2127 Chicken Farm

Source: Internet
Author: User

Topic Link: Chicken Farm

This is probably the two days to do the most smooth together, after reading the 1 A. However, the reading of the puzzle.

Feeling is a maths problem.

Start thinking about if the two-edge enumeration range is definitely timed out. But like this, paper-cut is still hopeful.

Enumerates the extents of the first edge, finds the number of possible values for the second edge on each value of the first edge, and then finds the number of possible values for the third edge B.

In this case, the number of triangles that each value can make is a small value between A and B. "For what?" it's obvious.

Code knowledge is only used on both sides of the sum greater than the third side, this range of limits of thought worth learning ...

Attached code:

#include <stdio.h> #include <string.h> #include <iostream>using namespace Std;int main () {    int n;< C1/>int L1, R1, L2, R2, L3, R3;    while (CIN >> N) {        int ans = 0;        CIN >> L1 >> R1 >> L2 >> R2 >> L3 >> R3;        for (int i=l1; i<=r1; ++i) {            int temp = (n-i)/2;            if (i > Temp) break;            A2 left Border            int min2 = max (L2, I);//a2>a1            min2 = max (min2, (n-i*2)/2+1);//A3<A1+A2            //A2 right boundary            int max2 = min (r2, (n-i)/2); A1<A3            //A3 left Border            int min3 = max (L3, N-I-MAX2);//a3>a2            int max3 = min (r3, n-i-min2);//a3>a2
   
    temp = min (max2-min2+1, max3-min3+1);            if (temp>0)                ans + = temp;        }        printf ("%d\n", ans);    }    return 0;}
   

  

Fzu 2127 Chicken Farm

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.