UVA-11490 Just Another problem

Source: Internet
Author: User

The main idea: a pxq lattice composed of p*q dots (forming a rectangle). Remove all points from the inner point of the two squares, which are equal in length, with respect to the centerline symmetry in the position, and the number of layers of the remaining points in the upper and lower left and right sides of each square. Now it is known that the number of points left to be removed from the remainder of S, the number of points may be taken away.

Problem analysis: When taking away the 2n^2 point, according to the conditions in the problem set, the number of points remaining is s=7nk+6k^k (where k is the number of layers). Enumeration k, can get n, problem solved.

The code is as follows:

# include<cstdio>using namespacestd;# define LLLong LongConstLL mod=100000007;intMain () {LL s;  while(~SCANF ("%lld", &s) &&s) {intyy=1;  for(LL k=1;6*k*k<s;++k) {LL U=s-6*k*K; if(u% (7*k) = =0) {LL n=u/(7*K)%MoD; printf ("Possible Missing soldiers =%lld\n", n*n*2%MoD); YY=0; }        }        if(yy) printf ("No Solution possible\n"); printf ("\ n"); }    return 0;}

UVA-11490 Just Another problem

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.