hdu 1396

来源:互联网 发布:淘宝订单监控 编辑:程序博客网 时间:2024/06/05 06:40

递推,找规律

#include <iostream>#include <cstdio>using namespace std;int count[510];int main(){count[1]=1;int i,j;for(i=2;i<=500;i++){int t=count[i-1];for(j=1;j<=i;j++) t=t+i+1-j;for(j=1;i-j>=j;j++) t=t+i-j+1-j;count[i]=t;}int n;while(cin>>n) cout<<count[n]<<endl;return 0;}