首先n为偶数必然没有n为奇数优==

而n为奇数最多能放(n^n+1)/2个1

特别注意特判x=3的时候需要5个,因为3个那样放就相邻了==

 1 #include<stdio.h>
 2 #include<string.h>
 3 #include<algorithm>
 4 using namespace std;
 5 int main()
 6 {
 7   int n,i,tmp;
 8   scanf("%d",&n);
 9   if (n==3) {printf("5\n"); return 0; }
10   for (i=1;;i+=2)
11   {
12     tmp=(i*i+1)/2;
13     if (n<=tmp) {printf("%d\n",i); return 0; }
14   }
15 }

题目链接:http://codeforces.com/problemset/problem/201/A

相关文章:

  • 2021-10-03
  • 2021-04-05
  • 2021-12-13
  • 2022-02-10
  • 2022-12-23
  • 2022-01-16
  • 2021-06-12
  • 2022-12-23
猜你喜欢
  • 2021-05-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2022-12-23
  • 2022-12-23
  • 2021-08-19
相关资源
相似解决方案