## 11063 - B2-Sequence

Moderator: Board moderators

rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

### Re: 11063 - B2-Sequence

Part that has bug;

Code: Select all

``````      int pot = 1;
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
if(a[i]<pot)b=0;
pot = a[i];
}``````

Code: Select all

``````      for(i=1;i<=k;i++)
{
for(j=i+1;j<=k;j++)
{``````
-----
Rio

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11063 - B2-Sequence

I know from the problem that I had to check all the sums are equal or not.
I was using nested loop to check all the values:

Code: Select all

``````for(i=1;i<=k;i++)
{
for(j=i+1;j<=k;j++)
{``````
how it can be wrong?
In the other side while taking input i was testing whether they satisfy B2 sequence or not.
What is the mistake there?
try_try_try_try_&&&_try@try.com
This may be the address of success.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11063 - B2-Sequence

I changed my code on that two point but got WA again!!!(sorry for my previous post).

Code: Select all

``removed``
Last edited by Obaida on Sun Nov 23, 2008 9:27 am, edited 1 time in total.
try_try_try_try_&&&_try@try.com
This may be the address of success.

x140l31
Learning poster
Posts: 69
Joined: Tue Jan 30, 2007 12:51 am

### Re: 11063 - B2-Sequence

what's wrong in this code? T.T

Code: Select all

``Removed after AC``
Last edited by x140l31 on Tue Jun 30, 2009 9:01 pm, edited 1 time in total.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 11063 - B2-Sequence

I have my Acc.. now.
try_try_try_try_&&&_try@try.com
This may be the address of success.

samin
New poster
Posts: 6
Joined: Fri Jul 18, 2008 9:29 pm

### 11063 - B2-Sequence

plz can any one tell me what's the problem in thi code?

Code: Select all

``````#include<stdio.h>

int uni[20001];

int main()
{
int a[100];
int i,j,n,t=0,flag;

while(scanf("%d",&n)!= EOF)
{
for(i=0;i<=20000;i++)
uni[i] = 0;
t++;
flag = 1;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]<=0)
flag = 0;
}

for(i=0;i<=n-1 && flag;i++)
{
for(j=i;j<=n-1;j++)
{
if(uni[a[i]+a[j]] == 1 || a[i] >= a[j])
{
flag = 0;
break;
}
else
uni[a[i]+a[j]] = 1;
}
}
if(flag)
printf("Case #%d: It is a B2-Sequence.\n\n",t);
else
printf("Case #%d: It is not a B2-Sequence.\n\n",t);
}
return 0;
}``````

rehan
New poster
Posts: 5
Joined: Thu Dec 25, 2008 1:24 pm

### Re: 11063 - B2-Sequence

can any one tell me what is the wrong with my code

Code: Select all

``````#include<stdio.h>

int main()
{
int a[1000],m=0,n,j,i,k,l,x,y,c[1000];

while(scanf("%d",&n)==1)
{
m++;
for(i=0;i<n;i++)
scanf("%d",&a[i]);

l=0;

for(i=0;i<n;i++)
for(j=i+1;j<n;j++)
if(a[j]<=a[i])
{
l=0;
break;
}

k=0;
for(i=0;i<n;i++)
for(j=i;j<n;j++)
{
c[k]=a[i]+a[j];
k++;
}

for(i=0;i<k-1;i++)
for(j=i+1;j<k;j++)
{
if(c[i]==c[j])
{l=1;
break;}
}
if(l==0)
printf("Case #%d: It is a B2-Sequence.\n",m);
else
printf("Case #%d: It is not a B2-Sequence.\n",m);
}

return 0;
}

``````

mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Contact:

### Re: 11063 - B2-Sequence

To rehan,
After each test case you must print a blank line.
and to samin,
For Input :

Code: Select all

``````2
2 10``````
Output :

Code: Select all

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

``````
For both of you , check the board first and remove your code after AC.

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

### Re: 11063 - B2-Sequence

AT first i see the topic present on the board

all is ok BUT the judge saw WA
here is my code plz help me...

Code: Select all

``````CUT.............after ACC........ :lol:  :lol:  :lol:
``````
Last edited by saiful_sust on Sat Sep 19, 2009 12:43 am, edited 1 time in total.

lionking
New poster
Posts: 9
Joined: Tue Feb 17, 2009 6:46 pm

### Re: 11063 - B2-Sequence

could someone tell me why I always get WA?

I have check following terms:
i. the sequence is strickly increase
ii. the first term is larger than 0
iii. all pairwise sums are different

Do I lose something?

plz tell me~~~

thanks!!

Here is my code:

Code: Select all

``````remove after got AC
``````

liauys
New poster
Posts: 7
Joined: Thu Jul 02, 2009 6:37 pm

### Re: 11063 - B2-Sequence

Sorry, code removed

Hi saiful.. These are the cases for you:

Code: Select all

``````2
2 2

4
1 3 6 9
``````
None of them is b2 sequence.
Last edited by liauys on Fri Oct 02, 2009 2:30 pm, edited 1 time in total.

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

### Re: 11063 - B2-Sequence

Hi liauys thanks for ur help .......
one thing u do not need to show all my code here

PLZ remove my code only.......
I found my mistake and got acc.....

keep posting.....thanks

hafez_hafez
New poster
Posts: 1
Joined: Thu Oct 29, 2009 7:11 pm

### Re: 11063 - B2-Sequence

i've alot of WA :s why anybody helppppppppppppppppppp

#include<iostream>
#include<string>

using namespace std ;
bool aray[1000000];
int ar[100000];

int main()
{

int n , sum ;
int t = 1 ;
while(cin >> n )
{
fill(aray , aray+1000000 , false);
bool flage = true , flg = false;

for(int i = 0 ; i < n ; i++)
{
cin >> ar ;

}
for(int i = 0 ; i < n ; i ++)
{
if(ar < 1 || ar <= ar[i-1])
{
cout <<"Case #"<<t<<": It is not B2-Sequence."<<endl<<endl;
flg = true;
break;
}
}

if(flg)
{
t++;
continue;
}

for(int i = 0 ; i < n ; i++)
{
for(int j = i ; j < n ; j++)
{
sum = ar + ar[j] ;
if(aray[sum])
{
flage = false ;
break;
}

aray[sum] = true ;

}
if(!flage)
{
cout << "Case #"<<t<<": It is not a B2-Sequence."<<endl<<endl;
break;
}

}
if(flage)
cout <<"Case #"<<t<<": It is a B2-Sequence."<<endl<<endl;
t++;

}
return 0;
}

lnr
Experienced poster
Posts: 142
Joined: Sat Jun 30, 2007 2:52 pm

### Re: 11063 - B2-Sequence

Accepted.

Eather
New poster
Posts: 28
Joined: Thu Jan 28, 2010 2:23 pm

### Re: 11063 - B2-Sequence

Why WA?

Code: Select all

``````                           /*in the name of Allah */

#include <list>
#include <deque>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<limits>
#include <stack>
#include<vector>
#include<cstring>
#include<cstdio>
using namespace std;

# define MEM(array,w)   memset(array,w,sizeof array)
# define fr(i,a,b) for(int (i) = a ; i < b ; i++)
# define SET set<int>::iterator it = s.begin(); it != s.end();it++
# define ULL unsigned long long
# define eps 1e-9
# define LL  long long
# define IS istringstream
# define fri(i,a,b) for(int (i) = a ; i <= b ; i++)
# define mfr(i,a,b) for(int (i) = a ; i > b ; i--)
# define mfri(i,a,b) for(int (i) = a ; i >= b ; i--)
# define PII pair<int , int>
#define all(c) (c).begin(), (c).end()
#define maxint 1 << 31 - 1
#define GI ({int _t; scanf("%d", &_t); _t;})
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REP(i, a) FOR(i, 0, a)
template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();}
int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;}
#define DBG(x) cout << #x << "::" << x << endl;
#define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;}

bool isprime(int n)
{
if( n<2) return 0;

for( int i=2; i*i<=n ; i++)if(n%i==0)return 0; return 1;

return 0;
}
int main()
{
int Ti;
int ca=0;

while(cin>>Ti){

int Arr[102];

int flg=0;
for(int i=0;i<Ti;i++)
{
cin>>Arr[i];

if(i>0 && Arr[i]<=Arr[i-1])flg=1;
if(i>=2)if(Arr[i]==(Arr[i-1]+Arr[i-2]))flg=1;
}

if(flg==1)
{
printf("Case #%d: It is not a B2-Sequence.\n\n",++ca);
}
else printf("Case #%d: It is a B2-Sequence.\n\n",++ca);

}

return 0;
}
``````