A. Clear Symmetry

题目连接:

http://codeforces.com/contest/201/problem/A

Description

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 Ai, 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: Ai, j = An - i + 1, j and Ai, j = Ai, 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.

Input

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

Output

Print a single number — the sought value of n.

Sample Input

4

Sample Output

3

Hint

题意

给你一个x,你需要找到一个最小的正方形,使得这个正方形里面有x个1

这个正方形,需要满足1的方格不能相邻,且a[i][j]=a[n-i][j],a[i][j]=a[i][n-j],即上下对称,左右对称

然后问你边长最小是多少

题解:

数学题 打表

偶数是不考虑的,大概可以画画,很难满足对称性,且中间四个格子是浪费的

然后只用考虑奇数的情况

打表之后发现,奇数我们发现奇数长度的正方形能够容纳的1的个数满足公式2x(x+1)+1;

然后套进去就好了

代码

#include<bits/stdc++.h>
using namespace std; int f(int x)
{
x--;
return 2*x*(x+1)+1;
}
int main()
{
int n;
scanf("%d",&n);
if(n==3)return puts("5");
int ans = 1;
while(f(ans)<n)
ans++;
cout<<ans*2-1<<endl;
}

Codeforces Round #127 (Div. 1) A. Clear Symmetry 打表的更多相关文章

  1. Codeforces Round #127 (Div. 2)

    A. LLPS 长度最大10,暴力枚举即可. B. Brand New Easy Problem 枚举\(n\)的全排列,按题意求最小的\(x\),即逆序对个数. C. Clear Symmetry ...

  2. Codeforces Round #127 (Div. 1) E. Thoroughly Bureaucratic Organization 二分 数学

    E. Thoroughly Bureaucratic Organization 题目连接: http://www.codeforces.com/contest/201/problem/E Descri ...

  3. Codeforces Round #127 (Div. 1) D. Brand New Problem 暴力dp

    D. Brand New Problem 题目连接: http://www.codeforces.com/contest/201/problem/D Description A widely know ...

  4. Codeforces Round #127 (Div. 1) C. Fragile Bridges dp

    C. Fragile Bridges 题目连接: http://codeforces.com/contest/201/problem/C Description You are playing a v ...

  5. Codeforces Round #127 (Div. 1) B. Guess That Car! 扫描线

    B. Guess That Car! 题目连接: http://codeforces.com/contest/201/problem/B Description A widely known amon ...

  6. Codeforces Round #422 (Div. 2)E. Liar sa+st表+dp

    题意:给你两个串s,p,问你把s分开顺序不变,能不能用最多k段合成p. 题解:dp[i][j]表示s到了前i项,用了j段的最多能合成p的前缀是哪里,那么转移就是两种,\(dp[i+1][j]=dp[i ...

  7. Codeforces Round #278 (Div. 1) B - Strip dp+st表+单调队列

    B - Strip 思路:简单dp,用st表+单调队列维护一下. #include<bits/stdc++.h> #define LL long long #define fi first ...

  8. Codeforces Round #493 (Div. 1) B. Roman Digits 打表找规律

    题意: 我们在研究罗马数字.罗马数字只有4个字符,I,V,X,L分别代表1,5,10,100.一个罗马数字的值为该数字包含的字符代表数字的和,而与字符的顺序无关.例如XXXV=35,IXI=12. 现 ...

  9. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

随机推荐

  1. [Leetcode Week16]Range Sum Query - Mutable

    Range Sum Query - Mutable 题解 原创文章,拒绝转载 题目来源:https://leetcode.com/problems/range-sum-query-mutable/de ...

  2. 64_g1

    GAPDoc-1.5.1-12.fc26.noarch.rpm 13-Feb-2017 22:37 1082286 GAPDoc-latex-1.5.1-12.fc26.noarch.rpm 13-F ...

  3. java.lang.ClassCastException: org.springframework.web.filter.CharacterEncodingFilter cannot be cast

    严重: Exception starting filter encodingFilterjava.lang.ClassCastException: org.springframework.web.fi ...

  4. 七:zooKeeper开源客户端ZkClient的api测试

    ZkClient是Gitthub上一个开源的ZooKeeper客户端.ZKClient在ZooKeeper原生API接口之上进行了包装,是一个更加易用的ZooKeeper客户端.同时ZKClient在 ...

  5. Go语言用mock server模拟调用(httptest)

    mock是个好东东, 在大项目或大公司,很实用, 因为很多环境不是随时在开发环境可得的. package main import ( "testing" "net/htt ...

  6. Delphi使程序的窗口出现在最前面并激活

    procedure setAppFront(); //使程序的窗口出现在最前面并激活 var pt, OldPt, NewPt: TPoint; begin //判断Application是否最小化, ...

  7. 使用vue2.0 vue-router vuex 模拟ios7操作

    其实你也可以,甚至做得更好... 首先看一下效果:用vue2.0实现SPA:模拟ios7操作 与 通讯录实现 github地址是:https://github.com/QRL909109/ios7 如 ...

  8. loadrunner中文件的操作

    loadrunner中文件的操作 我们可以使用fopen().fscanf().fprintf().fclose()函数进行文件操作,但是因为LoadRunner不支持FILE数据类型,所以我们需要做 ...

  9. YII2源码阅读:autoload_real.php 22~23行

    spl_autoload_register(array('ComposerAutoloaderInit32b8eb537f8e12e57c5e7bade69d01f0', 'loadClassLoad ...

  10. Storm基本概念以及Topology的并发度

    Spouts,流的源头 Spout是Storm里面特有的名词,Stream的源头,通常是从外部数据源读取tuples,并emit到topology Spout可以同时emit多个tupic strea ...