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

1781 why wa,who can tell me.thank you!

Posted by huangtaiquan at 2007-12-11 21:59:18
#include<stdio.h>
#include<string.h>
#include<math.h>

int ps[100];
void local()
{
  int i;
  for(i=0; i<=31; i++)
      ps[i]=pow(2.0,i);
}
int localdanger(int n)
{
   int i,s;
   long long int sum=0;
   s=n;
   for(i=0; i<=31; i++)
   {
      if(n>=ps[i])
      {
         n-=ps[i];
         sum+=ps[i];
       }
      else
         break;
   } 
   if(s==sum)
     return s;
   else 
     return ((s-sum)*2-1);
}
int main()
{
   int n;
   char s[5];
   local();
   while(scanf("%s",s)&&strcmp(s,"00e0")!=0)
   {
      n=(s[0]-'0')*10+s[1]-'0';
      if(n==0)
        continue ;
      else
      { 
        n=n*pow(10,s[3]-'0');
        printf("%d\n",localdanger(n));
      }
   }
   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