Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
先变成线性 再分类#include<stdio.h> int t,n; int kan(int n) { if(n==1) return 0; if(n==2) return 1; if(n%2==0) return 2*kan(n/2)+n*n/4; else return kan((n-1)/2)+kan((n+1)/2)+(n*n-1)/4; } int wa(int n) { if(n==1) return 0; if(n==2) return 0; int k=(n-2)%2; switch (k) { case 1:return kan(n/2)+kan(n/2+1); case 0:return 2*kan(n/2); } } int main() { scanf("%d",&t); while(t--) { scanf("%d",&n); printf("%d\n",wa(n)); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator