Codeforces 201A Clear symmetry

Source: Internet
Author: User

 

consider some square matrix < Span class= "Tex-span" > A  with side  n  consisting of Zeros and Ones. There Are  n  rows numbered From 1 to   n  from top to bottom and  n   Columns numbered From 1 to  n  from left To the This matrix. We ' ll denote the element of the matrix which is located at the intersection of The  i - Row and The  J -th column As  A i , J .

let's Call Matrix  a  clear if no, cells containing ones have A common side .

let's Call Matrix  A  symmetrical if it matches the matrices formed from it By a horizontal and/or a vertical reflection. Formally, for each pair  ( i , J )   (1≤ I , j ≤ n )  both of the following conditions must be Met:  A  i , j = A n - i  + 1, J  and  A i , j = A i , n - J + 1.

Let's define the sharpness of matrix A as the number of ones in it.

Given integer x, your task is to find the smallest positive integer n such that there exists a C Lear symmetrical matrix A with side n and sharpness x.

Input

The only line contains a single integer x (1≤ x ≤100)-the required sharpness of the matrix.< /c3>

Output

Print a single number-the sought value of n.

Sample Test (s)input
4
Output
3
input
9
OUTPU5given a matrix of several definitions (shape, cleanliness, uniformity), each time an x is given to satisfy the n*n matrix of the shape X, neatness, uniformity, the smallest nyy, you can know that n is even when the optimal solution must not be. When n is odd: if x is within [l,r], N is the smallest of the a[x] rows, then the smallest of n is a[x]+2 in the range [r+1,r+ (a[x]+1) * *].1 to 5, then 6~100 will be able to push a bit.
1#include <cstdio>2 3 Const intmaxn= the;4 5 intA[MAXN];6 7 intMain ()8 {9a[1]=1;Tena[3]=5; Onea[2]=a[4]=a[5]=3; A      for(intI=5;i<MAXN;) -     { -         intX= (a[i]+1)*2; the          for(intj=i+1; j<=i+x;j++) -a[j]=a[i]+2; -i+=x; -     } +  -     intx; +      while(SCANF ("%d", &x)! =EOF) A     { atprintf"%d\n", a[x]); -     } -  -     return 0; -  -}
View Code






Note

The figure below shows the matrices, correspond to the samples:

Codeforces 201A Clear symmetry

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.