Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

先变成线性 再分类

Posted by speedcell4 at 2011-01-28 16:44:58 on Problem 1455
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator