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

跪求测WA的数据!

Posted by tiaotiaoshu at 2008-06-09 15:33:15 on Problem 3077
本地测试都是正确的,为什么WA!
#include<stdio.h>
long mi(int a,int n)
{
     int i;
     long sum=1;
     if(n==0)
         sum=1;
     else
     {
         for (i=0;i<n;i++)
             sum=sum*a;
     }
     return sum; 
}
void main()
{
     int n,i,j,k,m;
     long num;
     scanf("%d",&n);
     for(i=0;i<n;i++)
     {
          scanf("%ld",&num);
          for(j=8;j>0;j--)
          {
              if(num>mi(10,j))
                  break;
          }
          m=0;
          for(k=0;k<10&&m!=1;k++)
          {
               if(num<k*mi(10,j))
               {
                   m=1;
                   break;
               }
          }
          if(num<10)
              num=num;
          else if(num>((k-1)*mi(10,j)+4*mi(10,j-1)))
              num=(k)*mi(10,j);
          else
              num=(k-1)*mi(10,j);
          printf("%ld\n",num);
     }
}

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