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 sunmoonstar_love at 2005-07-12 20:08:37 on Problem 2193
#include<stdio.h>
#include<math.h>
int c,n,m,i,nCase;
long long a[4001];
int main()
{
    a[1] = 0;
    for(i=2; i<=4000; i++)
    {
        a[i] = a[i-1] + i/2;
   //     printf("%d:%d ",i,a[i]);
    }    
//    printf("%d\n",a[2000]);
    scanf("%d",&c);
    for(nCase=1; nCase<=c; nCase++)
    {
        scanf("%d%d",&n,&m);
        if(n==1)
        {
            printf("Case %d: n = %d, m = %d, # lists = %d\n",nCase,n,m,m);
            continue;
        }    
        if(m<pow(2,n-1))
        {
            printf("Case %d: n = %d, m = %d, # lists = %d\n",nCase,n,m,0);
        }
        else
        {
            printf("Case %d: n = %d, m = %d, # lists = %d\n",nCase,n,m,a[m+2-int(pow(2,n-1))]);
        }        
    }     
    return 0;
}    

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