Page 2 of 2

Re: Skew Binary: got WA

Posted: Sat Aug 28, 2010 1:48 pm
by sazzadcsedu
First things to note:

why you are creating a new thread while it is already existing?

your code even not pass the sample input.So how do you expect to get Acc!!!.

Code: Select all

for( i = len-1 ; i >= 0 ; i-- )
{
            dec = dec + (input[i]-'0')*(factor-1) ;

            factor = factor * 2 ;
}
Do you think this part is right??For example

Code: Select all

input : 20
your output:2
Actual output: 6

Re: Skew Binary: got WA

Posted: Thu Sep 02, 2010 12:57 pm
by dewsworld
Ooops, I actually didn't find any thread about Skew binary while googling.
And I found my fault. It's pretty silly, I didn't read the question carefully.
Power inits from 2^1 -1 not 2^0 -1 Got AC after that... :)

Why i am getting WA for this ?

Posted: Fri Dec 31, 2010 10:43 am
by akshit
#include<iostream>
using namespace std;
long long int power(long long int n,long long int e)
{
long long int prod,i;
prod=n;
for(i=0;i<e-1;i++)
n=prod*n;
if(e==0)
return 1;
else
return n;
}
int main()
{
long long int m,p,k,q,sum,i,r,j,b[500],a[500];
char c[100];
gets(c);
for(i=0;c!='\0';i++)
{
a=(int)c;
a=(a-48);

}




while(a[0]!=0)
{

q=0;sum=0;
while(i>=0)
{

b[q]=(((power(2,q+1))-1)*a[i-1]);
sum=sum+b[q];
q++;
i--;
}


cout<<sum<<endl;


gets(c);
for(i=0;c!='\0';i++)
{
a=(int)c;
a=(a-48);

}
}



//system("pause");
return 0;
}

Re: Skew Binary: got WA

Posted: Thu Jan 13, 2011 7:39 pm
by sazzadcsedu
Your program even don't pass the sample input.