日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

*【CodeForces - 202C 】Clear Symmetry (思维,找规律,特判)

發布時間:2023/12/10 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 *【CodeForces - 202C 】Clear Symmetry (思维,找规律,特判) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題干:

Consider some square matrix?A?with side?n?consisting of zeros and ones. There are?nrows 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.

Examples

Input

4

Output

3

Input

9

Output

5

Note

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

?

解題報告:

? ? 呵呵,打表找規律,首先可以發現n為偶數一定不行(比賽時1minAC的神仙不知道是怎么看出來的)

? ? 然后,除了3這個數,其他的都可以找個規律填數就可以了。

AC代碼:

#include<iostream> #include<algorithm> #include<queue> #include<map> #include<vector> #include<set> #include<string> #include<cmath> #include<cstring> #define ll long long #define pb push_back #define pm make_pair #define fi first #define se second using namespace std; const int MAX = 2e5 + 5; ll x; int main() {int biao[25] = {0};cin>>x;for(int i = 1; i<=20; i++) {int now = (i+1)/2;if(i%2 == 0) biao[i] = biao[i-1];else biao[i] = now*now + (now-1)*(now-1);} // for(int i = 1; i<=17; i++) printf("%d\n",biao[i]);if(x== 3) printf("5\n");else printf("%d\n",lower_bound(biao+1,biao+20+1,x) - biao);return 0 ;}

?還未看懂的證明:https://blog.csdn.net/qq_24451605/article/details/48677823

總結

以上是生活随笔為你收集整理的*【CodeForces - 202C 】Clear Symmetry (思维,找规律,特判)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。