Advertisement
Farjana_akter

Untitled

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