2014
03-06

# Build a Fence

There is a wall in your backyard. It is so long that you can’t see its endpoints. You want to build a fence of length L such that the area enclosed between the wall and the fence is maximized. The fence can be of arbitrary shape, but only its two endpoints may touch the wall.

The input consists of several test cases.
For every test case, there is only one integer L (1<=L<=100), indicating the length of the fence.
The input ends with L=0.

The input consists of several test cases.
For every test case, there is only one integer L (1<=L<=100), indicating the length of the fence.
The input ends with L=0.

1
100
0

0.16
1591.55

#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

const double PI = acos(-1.0);
int n;

int main() {
while (scanf("%d", &n) != EOF) {
if (n == 0) break;
printf("%.2lf\n", (n / PI) * (n / PI) * PI * 0.5);
}
return 0;
}

1. 谁男主谁女主啊！还以为游浩贤是男主，小律是女主呢？！看了评论都没心情看了。靠！作者是不是有病，游律党还是有的。特么居然把游浩贤写成她舅，没见过这么傻X的剧情。（现看到15话）

2. 老实说，这种方法就是穷举，复杂度是2^n，之所以能够AC是应为题目的测试数据有问题，要么数据量很小，要么能够得到k == t，否则即使n = 30，也要很久才能得出结果，本人亲测

3. 为什么for循环找到的i一定是素数叻，而且约数定理说的是n=p1^a1*p2^a2*p3^a3*…*pk^ak，而你每次取余都用的是原来的m，也就是n

4. 约瑟夫也用说这么长……很成熟的一个问题了，分治的方法解起来o(n)就可以了，有兴趣可以看看具体数学的第一章，关于约瑟夫问题推导出了一系列的结论，很漂亮