10
15
2015
0

[BZOJ1600] [Usaco2008 Oct] 建造栅栏

这题是一个打表找规律。

据说这题可以dp,但是我并不想写。(懒癌晚期)

具体的找规律方式:点击这里

dp:点击这里

#include<cstdio>

int n,f[2505];

int main(){
freopen("1600.in","r",stdin);
freopen("1600.out","w",stdout);
scanf("%d",&n);
f[4]=1;
for(int i=5;i<=n;i++){
    if(i&1)f[i]=f[i-1]+(i-2)*(i/2-1);
    else f[i]=f[i-1]+i/2-1;
}
printf("%d\n",f[n]);
return 0;
}
Category: BZOJ | Tags: bzoj | Read Count: 565

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter

Host by is-Programmer.com | Power by Chito 1.3.3 beta | Theme: Aeros 2.0 by TheBuckmaker.com