Page 2 of 2
Re: 11398 - The Base-1 Number System
Posted: Tue Oct 07, 2008 10:16 pm
by x140l31
lnr wrote:To x140l31
Try this
Input:
Output:
Thanks all.

why!!!
000 is ignored (it's a valid input? doesn't matter...) RESULT = 0
00 FLAG = 0 RESULT = 0
0 FLAG = 1 RESULT = 0
00 FLAG = 0 RESULT = 0
000 push 3-2=1 digits of FLAG = 0 RESULT = 0
result = 0
Re: 11398 - The Base-1 Number System
Posted: Wed Oct 08, 2008 6:35 am
by lnr
I am very sorry.
Input:
Output:
I updated the output.
Re: 11398 - The Base-1 Number System
Posted: Wed Oct 08, 2008 7:17 am
by lnr
To x140l31
Submit your code again.
I did not know that GNU C++ compiler supports and operator.
Code: Select all
while (cin >> block and block != "~")
is similar to
Code: Select all
while (cin >> block && block != "~")
Returning a value from int main() is a good practice.
You will get accepted.
May be you submitted wrong code before.
And don't forget to remove your code.
Re: 11398 - The Base-1 Number System
Posted: Wed Oct 08, 2008 7:50 pm
by x140l31
lnr wrote:To x140l31
Submit your code again.
I did not know that GNU C++ compiler supports and operator.
Code: Select all
while (cin >> block and block != "~")
is similar to
Code: Select all
while (cin >> block && block != "~")
Returning a value from int main() is a good practice.
You will get accepted.
May be you submitted wrong code before.
And don't forget to remove your code.
Thanks all.
I changed "and" to "&&" and i got AC...
why?
I always used "and" in al my programs, and never I got any problem :?
Re: 11398 - The Base-1 Number System
Posted: Wed Jan 28, 2009 4:35 pm
by nayimsust
you must get inputs by using either scanf("%s") or scanf("%c")
because input may be given in the following format
input:
0000 0 0000 00
000 0 0000 #
output:
27
may it helps you

Re: 11398 - The Base-1 Number System
Posted: Mon Jun 22, 2009 10:50 pm
by sazzadcsedu
nayimsust wrote-
you must get inputs by using either scanf("%s") or scanf("%c")
because input may be given in the following format
thats not true.you can use gets to take input.because each block is seperated by a space.
so the judge input is
Code: Select all
look like
0000 0 0000 00(space here)
000 0 0000 #
not like
0000 0 0000 00(without space)
000 0 0000 #
and first block may contain more than two 0.so your code need to ignore it.and when there is a consequetive block of one and two zero,and then larger block,u should consider the last (one/two) no. zero block for the larger block.
Re: 11398 - The Base-1 Number System
Posted: Tue Nov 08, 2011 11:35 pm
by buppy
can any one help why i am getting wa,
Code: Select all
#include<stdio.h>
#include<math.h>
int main()
{
char ch,f,ch1[100];
int i,j,len,sp,c,d,o=0;
double sum,sum1,k;
len=0;
sp=0;
j=0;
while(scanf("%c",&ch)==1){
if(ch=='0')
len++;
else if(ch==' ') {
sp++;
if(sp==1&&len>2)
o=1;
else if((len==1||len==2)&&sp%2!=0)
{
c=len;
if(c==1)
f='1';
else
f='0';
}
else{
d=len-2;
for(i=0;i<d;i++)
ch1[i+j]=f;
j=i+j;
}
len=0;
}
else if(ch=='#'){
if(o==1)
sum1=0;
else{
k=0;
for(i=j-1;i>=0;i--){
sum=ch1[i]-48;
sum=sum*pow(2,k);
sum1=sum1+sum;
k++;
}
}
printf("%0.f\n",sum1);
sum1=0;
len=0;
sp=0;
j=0;
o=0;
}
else if(ch=='~')
break;
}
return 0;
}
Re: 11398 - The Base-1 Number System
Posted: Wed Jul 18, 2012 10:27 am
by Nafis0001
please someone help me....getting wrong answer
Code: Select all
#include<cstdio>
#include<vector>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{char a[1000];int i,j,l,x;
vector<int>v;
while(scanf("%s",a))
{if(a[0]=='~')
break; v.clear();x=0;
while(a[0]!='#')
{l=strlen(a);
if(l==1)
x=1;
if(l==2)
x=0;
else
{for(i=2;i<l;i++)
v.push_back(x);}
scanf("%s",a);}
int y=v.size();
double s,k;s=0;
for(i=y-1;i>=0;i--)
{k=pow(2,i);
s+=v[i]*k;}
printf("%.0lf\n",s);}
return 0;}
Re: 11398 - The Base-1 Number System
Posted: Thu Jul 19, 2012 3:36 am
by brianfry713
Don't use doubles.