Morass

b2

Mar 6th, 2016
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     long long n ,x=0 ;
  8.     int c,c2,t=1,cnt;
  9.     while(cin>>n)
  10.     {
  11.         cnt=0 ;
  12.         x=n*(n+1) ;
  13.         x/=2 ;
  14.         long long arr[n] ,sum[x];
  15.         c=0 ,c2=0;
  16.         for (int i=0 ; i<n ; i++)
  17.         {
  18.             cin>>arr[i] ;
  19.         }
  20.         c=*arr<1;
  21.         for (int i=0 ; i<n-1 ; i++)
  22.         {
  23.             if (arr[i+1]<=arr[i])
  24.             {
  25.                 c=1 ;
  26.             }
  27.         }
  28.         for (int i=0 ; i<n ; i++)
  29.         {
  30.  
  31.             for (int j=i ; j<n ; j++)
  32.             {
  33.                 sum[cnt]=arr[i]+arr[j] ;
  34.                 if (cnt<x)
  35.                 {
  36.                     cnt++ ;
  37.                 }
  38.             }
  39.         }
  40.  
  41.         for (int i=0 ;i<x ;i++)
  42.         {
  43.             for (int j=0 ;j<x ;j++)
  44.           {
  45.             if (sum[i]==sum[j] && i!=j )
  46.             {
  47.                 c2=1 ;
  48.             }
  49.           }
  50.         }
  51.         if (c==1 || c2==1)
  52.         {
  53.             cout<<"Case #"<<t<<": It is not a B2-Sequence."<<endl<<endl ;
  54.         }
  55.         else
  56.         {
  57.             cout<<"Case #"<<t<<": It is a B2-Sequence."<<endl<<endl ;
  58.         }
  59.         t++ ;
  60.     }
  61.  
  62.  
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment