CF201A.Clear Symmetry

普及/提高-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Consider some square matrix 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 right in 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 two 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 clear symmetrical matrix A with side n and sharpness x.

考虑一个边长为 nn 的方阵 AA,其中仅包含 00 和 11。该矩阵从上到下有 nn 行,编号为 11 至 nn;从左到右有 nn 列,编号也为 11 至 nn。我们将位于第 ii 行、第 jj 列的矩阵元素记作 Ai,jA_{i,j}。

若矩阵 AA 中任意两个值为 11 的格子均不相邻(即没有公共边),则称该矩阵为清晰的(clear)。

若矩阵 AA 在水平翻转和/或垂直翻转后保持不变,则称其为对称的(symmetrical)。形式化地说,对每一对 (i,j)(i,j)(其中 1≤i,j≤n1 \le i,j \le n),以下两个条件必须同时成立:

Ai,j=An−i+1, j且Ai,j=Ai, n−j+1.A_{i,j} = A_{n-i+1,\,j} \quad \text{且} \quad A_{i,j} = A_{i,\,n-j+1}.

定义矩阵 AA 的锐度(sharpness)为其所含 11 的个数。

给定整数 xx,你的任务是找出最小的正整数 nn,使得存在一个边长为 nn、锐度为 xx 的清晰且对称的矩阵 AA。

输入格式

The only line contains a single integer x (1 ≤ x ≤ 100) — the required sharpness of the matrix.

唯一一行包含一个整数 xx(1 ≤ x ≤ 1001 ≤ x ≤ 100)——矩阵所需的锐度。

输出格式

Print a single number — the sought value of n.

输出一个整数——所求的 nn 值。

输入输出样例

  • 输入#1

    4

    输出#1

    3
  • 输入#2

    9

    输出#2

    5

说明/提示

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

下图展示了与样本对应的矩阵:

输入解题思路,AI测评打分。不知道怎么写?

首页