在太平洋的一个小岛上,岛民想要建立一个环岛的堤坝,我们可以将小岛简化为一个二维平面,你需要使用K条边(这些边要么是水平或者垂直长度为1的边,要么是45度倾斜的长度为√2的边)围成一个多边形,多边形的顶点必须位于整点,然后要让围成的多边形面积最大,你需要求出最大面积是多少。
标签:csu
在太平洋的一个小岛上,岛民想要建立一个环岛的堤坝,我们可以将小岛简化为一个二维平面,你需要使用K条边(这些边要么是水平或者垂直长度为1的边,要么是45度倾斜的长度为√2的边)围成一个多边形,多边形的顶点必须位于整点,然后要让围成的多边形面积最大,你需要求出最大面积是多少。
输入包含多个测试实例,每组实例给出一个数K。(3≤K≤2000000000)
每一行对应一个要求的答案。(保留一位小数)
3
4
5
6
0.5
2.0
2.5
4.0
#include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <math.h> #include <bitset> #include <list> #include <algorithm> #include <climits> using namespace std; #define lson 2*i #define rson 2*i+1 #define LS l,mid,lson #define RS mid+1,r,rson #define UP(i,x,y) for(i=x;i<=y;i++) #define DOWN(i,x,y) for(i=x;i>=y;i--) #define MEM(a,x) memset(a,x,sizeof(a)) #define W(a) while(a) #define gcd(a,b) __gcd(a,b) #define LL long long #define N 200005 #define INF 0x3f3f3f3f #define EXP 1e-8 #define lowbit(x) (x&-x) const int mod = 1e9+7; int main() { LL n,x,y; LL ans; while(~scanf("%lld",&n)) { ans = 0; x = n/4; y = n%4; if(y<2) ans = 4*x*x; else ans = 4*x*(x+1); if(y==1) ans+=2*x-1; else if(y==3) ans+=2*x+1; if(ans&1) printf("%lld.5\n",ans/2); else printf("%lld.0\n",ans/2); } return 0; }
标签:csu
原文地址:http://blog.csdn.net/libin56842/article/details/46596351