Codeforces 140F New Year Snowflake

Source: Internet
Author: User

F. New year Snowflake

As Gerald ..., in other words, on a New year Eve Constantine prepared an unusual present for the Beautiful Lady. The present is the magic of the New year snowflake, can make any dream come true.

The New year snowflake consists of tiny ice crystals, which can is approximately regarded as points on the plane. The beauty of the New year Snowflake is, it has a center of symmetry. This was a point such that for each crystal of the snowflake exists another crystal, symmetrical to it relative to that POI Nt. One of the crystals can is placed directly in the center of symmetry.

While Constantine is choosing a snowflake among millions of other snowflakes, no less symmetrical and no less magical, th En endured a difficult path through the drifts to the house of his mistress, while he is waiting with bated breath for a Few long moments before the Beautiful Lady opens the door, some of the snowflake crystals melted and naturally disappeared . Constantine is sure this there were no more than K of such crystals, because he handled the Snowflake very CA Refully. Now he's ready for demonstrate to the Beautiful Lady all the power of nanotechnology and restore the symmetry of snowflake S.

You is given the coordinates of the surviving snowflake crystals, given in nanometers. Your task is to identify all possible positions of the original center of symmetry.

Input

The first line contains integers n and k (1≤ n ≤200, 0≤ k ≤ -the number of the surviving snowflake crystals and the maximum number of melted crystals, correspondingly. Next n lines contain the coordinates of the crystals that is left in the following form: "x" c12>i yi". The coordinates is integers and does not exceed 5 108 in absolute value. All given points is different.

Output

The first line contains an integer c -the number of possible symmetry centers. Next C lines should contain the centers ' descriptions. Each symmetry center are described by a couple of coordinates "x y", separated by a space. Print the coordinates with absolute error is not exceeding 6. You is allowed to print the symmetry centers in any order. All printed points should is different. If there exist an infinite number of possible symmetry centers, print the single number "-1".

Examplesinput
4 0
0 0
0 1
1 0
1 1
Output
1
0.5 0.5
Input
4 2
0 0
0 1
1 0
1 1
Output
5
0.0 0.5
0.5 0.0
0.5 0.5
0.5 1.0
1.0 0.5
Input
4 4
0 0
0 1
1 0
1 1
Output
-1

Reference: http://blog.csdn.net/acdreamers/article/details/8521134
#include <cstdio>#include<cstring>#include<algorithm>using namespaceStd;typedefLong LongLL;Const intn=1e6+5;intd[5005][5005],am[5005],l[n],a[5005],sum[2],dp[2][5005],n,m,p;voidget_table () {d[0][0]=1; for(intI=1; i<= the; i++) for(intj=1; J<=min ( the, m); J + +) D[i][j]= (1ll*d[i-1][j]* (J-1) +d[i-1][j-1])%p; a[0]=am[0]=1; for(intI=1; I<=min (M, the); i++) {Am[i]=1ll*am[i-1]* (m-i+1)%p; A[i]=1ll*a[i-1]*i%p; }}intMain () {scanf ("%d%d%d",&n,&m,&p); Get_table (); for(intI=1; i<=n;i++) scanf ("%d",&L[i]); sum[0]=1; for(intI=1; i<=n;i++) { for(intj=1; j<=l[i];j++) {dp[1][j]=1ll*am[j]*d[l[i]][j]%p*sum[0]%p; if(j<=l[i-1]) {dp[1][j]-=1ll*a[j]*dp[0][j]%p*d[l[i]][j]%p; if(dp[1][j]<0) dp[1][j]+=p; } (sum[1]+=dp[1][J])%=p; } memcpy (dp[0],dp[1],4* (l[i]+1)); sum[0]=sum[1]; sum[1]=0; } printf ("%d\n", sum[0]); return 0;}

Codeforces 140F New Year Snowflake

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.