Page 5 of 5

### Re: 11063 - B2-Sequence

Posted: Wed Dec 22, 2010 9:22 am
I found a couple of mistakes...

Second,
if(i>=2)if(Arr==(Arr[i-1]+Arr[i-2]))flg=1;

this line is wrong.
Consider the test case:

3
1 3 4

The sequence is a B2 sequence but your output shows it is not a B2 sequence.

### Re: 11063 - B2-Sequence

Posted: Mon Jun 27, 2011 4:35 pm
After taking all the numbers as input, store them in an array. Now if ar < 1 it is not obviously a B2 Sequence(see the description again). Also ar[k] must be less than ar[k + 1] for it to be a B2 sequence. Also note that i <= j. So for the first sample input:
4
1 2 4 8
The sums should be calculated as: 1 + 1, 1 + 2, 1 + 4, 1 + 8, 2 + 2, 2 + 4.........8 + 8
Brute force is enough to solve this problem, so you don't need any optimization(unless you want a higher rank), there is a blank line after every test case(including the last one), and make sure to print a . at the end of each output. There ya go, you should get AC now  ### 11063 - B2-Sequence

Posted: Sat Jun 02, 2012 6:24 pm
for each (i,j) with i<=j ,I have saved value+value[j] in a set, not multiset. In multiset,same data can be presented more than one.

If there is no duplicate of value+value[j] for different pairs(i,j) with (i<=j).

then no. of elements in the set would be (n*(n-1))/2 + n = (n*n-n)/2

Otherwise it is not B2 sequence.

Although we have to check some other conditions such as value >= 1 && value[j] > value ( for j > i)

BUET
07 Batch

### Why WA in UVa: 11063 - B2-Sequence?

Posted: Thu Feb 14, 2013 9:22 am
I can't understand what's wrong in my code. Can anyone help me to fix my code? My Code is:

Code: Select all

``````#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int cases, i, number, caseno = 0;
while(scanf("%d", &cases) == 1)
{
int count = 0;
for(i = 1; i <= cases; i++)
{
scanf("%d", &number[i]);
}
for(i = 1; i <= cases; i++)
{
if(number[i+1] - number[i] == number[i])
{
count = 1;
}
}
if(count == 1)
{
printf("Case #%d: It is a B2-Sequence.\n", ++caseno);
}
else
{
printf("Case #%d: It is not a B2-Sequence.\n", ++caseno);
}
if(caseno > 0)
{
printf("\n");
}
}
return 0;
}
``````

### Re: Why WA in UVa: 11063 - B2-Sequence?

Posted: Thu Feb 14, 2013 9:18 pm
Input:

Code: Select all

``````4
1 2 3 3
4
15 16 17 18
4
-5 0 5 9
6
1 9 19 0 45 70
6
1 9 19 45 70 150
5
15 16 -1 17 18
4
2 2 2 3
4
2 2 2 2
4
1 9 18 36
5
1 9 10 18 36``````
Correct output:

Code: Select all

``````Case #1: It is not a B2-Sequence.

Case #2: It is not a B2-Sequence.

Case #3: It is not a B2-Sequence.

Case #4: It is not a B2-Sequence.

Case #5: It is a B2-Sequence.

Case #6: It is not a B2-Sequence.

Case #7: It is not a B2-Sequence.

Case #8: It is not a B2-Sequence.

Case #9: It is a B2-Sequence.

Case #10: It is not a B2-Sequence.

``````

### Re: Why WA in UVa: 11063 - B2-Sequence?

Posted: Mon Mar 18, 2013 6:54 pm
WHY WA !!?

Code: Select all

``````#include <iostream>
using namespace std;

int main ()
{
int t=1,num,sum,s,c;
bool res;
while (cin>>s)
{
res=true;
for (int j=0;j<s;j++)
cin>>num[j];

for (int k=0;k<s-1;k++)
if (num[k]<1 || num[k]>=num[k+1] )
{
res=false;
break;
}

c=0;

for (int i=0;i<s;i++)
for (int l=i;l<s;l++)
{
sum[c]= num[i]+num[l];
c++;
}

for (int x=0;x<s;x++)
for (int y=0;y<s;y++)
if (sum[x]==sum[y] && y!=x) res=false;
else continue;

if (res==true)
cout<<"Case #"<<t<<": It is a B2-Sequence."<<endl;
else if (res==false)
cout<<"Case #"<<t<<": It is not a B2-Sequence."<<endl;
cout<<endl;
t++;

}
return 0;
}``````

### Re: 11063 - B2-Sequence

Posted: Mon Mar 18, 2013 6:55 pm
WHY WA !!?

Code: Select all

``````#include <iostream>
using namespace std;

int main ()
{
int t=1,num,sum,s,c;
bool res;
while (cin>>s)
{
res=true;
for (int j=0;j<s;j++)
cin>>num[j];

for (int k=0;k<s-1;k++)
if (num[k]<1 || num[k]>=num[k+1] )
{
res=false;
break;
}

c=0;

for (int i=0;i<s;i++)
for (int l=i;l<s;l++)
{
sum[c]= num[i]+num[l];
c++;
}

for (int x=0;x<s;x++)
for (int y=0;y<s;y++)
if (sum[x]==sum[y] && y!=x) res=false;
else continue;

if (res==true)
cout<<"Case #"<<t<<": It is a B2-Sequence."<<endl;
else if (res==false)
cout<<"Case #"<<t<<": It is not a B2-Sequence."<<endl;
cout<<endl;
t++;

}
return 0;
}``````

### Re: 11063 - B2-Sequence

Posted: Mon Mar 18, 2013 10:22 pm
Don't double post.

### Re: Why WA in UVa: 11063 - B2-Sequence?

Posted: Tue Mar 19, 2013 8:31 pm
Doesn't match the sample I/O.

### Re: 11063 - B2-Sequence

Posted: Wed Apr 24, 2013 1:29 pm
Try this:

Code: Select all

``````3
1 3 5``````

### Re: 11063 - B2-Sequence

Posted: Tue Mar 25, 2014 3:43 pm
why do I get wrong answer Code: Select all

``````Yeah...This is a AC code. I just don't know why the system told that this is wrong answer before...
``````

### Re: 11063 - B2-Sequence

Posted: Wed Mar 26, 2014 12:51 am
That is AC code

### Re: 11063 - B2-Sequence

Posted: Fri May 30, 2014 2:05 pm

### Re: WA!!!

Posted: Sun Aug 16, 2015 10:27 am
plz help...

I've tried with a lot of i/o....but couldn't fix what's wrong with this==>

Code: Select all

``````
#include<stdio.h>
int main()
{
int i,j,k,x,y,z,n,tc=0,ara,f;
long sum;
while(scanf("%d",&n)==1){
tc++;
for(i=0; i<n; i++){
scanf("%d", &ara[i]);
}
f=0;
for(i=1; i<n; i++){
if(ara[i]<=ara[i-1] || ara[i-1]<1){
f=1;
break;
}
}
if(f==1){
printf("Case #%d: It is not a B2-Sequence.\n",tc);
continue;
}
k=0;
for(i=0; i<n; i++){
for(j=n-1;j>=i;j--){
sum[k] = ara[i]+ara[j];
k++;
}
}
z=0;
for(x=0; x<k; x++){
for(y=k-1; y>x; y--){
if(sum[x]==sum[y]){
z=1;
break;
}
}
if(z==1) break;
}
if(z==0) printf("Case #%d: It is a B2-Sequence.\n",tc);
else printf("Case #%d: It is not a B2-Sequence.\n",tc);
printf("\n");
}
return 0;
}``````