This one is a shitty problem.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
#include <iostream> #include <cstdio> #include <cstring> using namespace std; bool arr[20000+5]; int main() { int n,a,kase=1; int prev=-1; int val[105]; bool Bseq; while(scanf ("%d", &n) != EOF) { Bseq=1; for(int i=0;i<n;i++) { cin>>val[i]; } for(int i=0;i<n-1;i++) { if(val[i]<1 || val[i]>=val[i+1]) { Bseq=0; break; } } if(Bseq) { memset(arr,0,sizeof(arr)); for(int i=0;i<n;i++) { for(int j=i;j<n;j++) { a=val[i]+val[j]; if(arr[a]) { Bseq=0; i=j=n; } else arr[a]=1; } } if(Bseq) cout<<"Case #"<<kase++<<": It is a B2-Sequence.\n\n"; else cout<<"Case #"<<kase++<<": It is not a B2-Sequence.\n\n"; } else cout<<"Case #"<<kase++<<": It is not a B2-Sequence.\n\n"; } } |