Bzoj 1800 fly-Flying Chess

Source: Internet
Author: User

This problem is actually examined from which can find a few diameters, because this time the data range is small, so just set a two-dimensional array, record each point and each point from the zero-based position, and finally set a variable record perimeter, and finally use a loop to search the location is less than half the circumference of the data, Plus half of the perimeter, if there are any in the array, there is a total of k* (k-1)/2 rectangles if there are k.

The code is as follows (the code is slightly more cumbersome than the above method, but the basic idea is the same):

#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>using namespacestd;inti_number,i_temp;inti_place[100000];intI_total=0, i_side=0; intMain () {CIN>>I_number; i_place[0]=1;  for(intI=0; i<i_number;i++) {cin>>i_temp; I_total=i_total+i_temp; I_place[i_total]=1; }     for(intI=0; i<i_total/2; i++)    {        if(i_place[i]==1)        {            if(i_place[i_total/2+i]==1) {I_side=i_side+1; } }} cout<<i_side* (i_side-1)/2<<Endl; return 0;}
Thank you for watching my blog, if there is not enough to point out, thank you.

Bzoj 1800 fly-Flying Chess

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.