| ||||||||||
| 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 | |||||||||
1781 why wa,who can tell me.thank you!#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator