fork download
  1. /* ------------------------------------*/
  2. /* Name: Aseem Chakrabarthy */
  3. /* Institute:University Of Chittagong */
  4. /* Dept: CSE */
  5. /* Email: aseem.cse.cu@gmail.com */
  6. /* ------------------------------------*/
  7. #include<bits/stdc++.h>
  8. using namespace std;
  9. #define FR0(i,N) for(i=0;i<(N);i++)
  10. #define FR1(i,N) for(i=1;i<=(N);i++)
  11. #define FRN(i,k,N) for(i=k;i<(N);i++)
  12. #define pf printf
  13. #define db double
  14. #define max3(a,b,c) max(max(a,b),c)
  15. #define min3(a,b,c) min(min(a,b),c)
  16. #define sci(n) scanf("%d",&n)
  17. #define scl(n) scanf("%lld",&n)
  18. #define scf(n) scanf("%f",&n)
  19. #define scd(n) scanf("%lf",&n)
  20. #define scs(s) scanf("%s",&s)
  21. #define scll(n) scanf("%%I64d",&n)
  22. #define PI acos(-1.0)
  23. #define LL long long
  24. #define MX 1000005
  25. #define MOD 1000000007
  26. typedef long long int ll;
  27. bool status[1100002];
  28.  
  29. int main()
  30. {
  31. int n,a[102],i,j,t=1;
  32. while(scanf("%d",&n)!=EOF)
  33. {
  34. for(i=0; i<n; i++)
  35.  
  36. cin>>a[i];
  37.  
  38. bool flag = true;
  39. for(i=0; i<n-1; i++)
  40. {
  41. if(a[i]<1||a[i]>=a[i+1])
  42. {
  43. flag=false;
  44. i=n;
  45. }
  46. }
  47. if(flag)
  48. {
  49. map<int,int>m;
  50. m.clear();
  51. for(i=0; i<n; i++)
  52. {
  53. for(j=i; j<n; j++)
  54. {
  55. if(m[a[i]+a[j]]==1)
  56. {
  57. flag=false;
  58. i=j=n;
  59. }
  60. else
  61. m[a[i]+a[j]]=1;
  62. }
  63. }
  64. if(flag)
  65. {
  66. cout<<"Case #"<<t++<<": It is a B2-Sequence."<<endl<<endl;
  67. }
  68. else
  69. {
  70. cout<<"Case #"<<t++<<": "<<"It is not a B2-Sequence."<<endl<<endl;
  71. }
  72. }
  73. else
  74. {
  75. cout<<"Case #"<<t++<<": "<<"It is not a B2-Sequence."<<endl<<endl;
  76. }
  77.  
  78. }
  79.  
  80. }
  81.  
Success #stdin #stdout 0s 4492KB
stdin
4
1 2 4 8
4
3 7 10 14
stdout
Case #1: It is a B2-Sequence.

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