日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

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

題干:

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:

?

解題報告:

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

? ? 然后,除了3這個數(shù),其他的都可以找個規(guī)律填數(shù)就可以了。

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 (思维,找规律,特判)的全部內容,希望文章能夠幫你解決所遇到的問題。

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