SHARE
TWEET

Untitled

a guest Feb 15th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. /// Typedef
  6. typedef long long ll;
  7.  
  8. #define sc1(a) scanf("%lld",&a)
  9. #define sc2(a,b) scanf("%lld %lld",&a,&b)
  10.  
  11. #define pf1(a) printf("%lld\n", a)
  12. #define pf2(a,b) printf("%lld %lld\n",a,b)
  13.  
  14. #define mx 10000007
  15. #define mod 1000000007
  16. #define PI acos(-1.0)
  17.  
  18. #define size1 10005
  19.  
  20. int drx[8] = {-2,-2,-1,-1,1,1,2,2};
  21. int dcy[8] = {-1,1,-2,2,-2,2,-1,1};
  22.  
  23. int dirx[4] = { -1, 0, 1, 0 };
  24. int diry[4] = { 0, -1, 0, 1 };
  25.  
  26. int main()
  27. {
  28.     ll tc, num, t = 1;
  29.  
  30.     // freopen("/opt/Coding/clion code/input.txt", "r", stdin);
  31.     //freopen("/opt/Coding/clion code/output.txt", "w", stdout);
  32.  
  33.     while (cin >> num){
  34.  
  35.         ll arr[num + 5];
  36.  
  37.         for(ll i = 1; i <= num; i++){
  38.             sc1(arr[i]);
  39.         }
  40.  
  41.         cout << "Case #" << t++ << ": ";
  42.  
  43.         for(ll i = 1; i <= num; i++){
  44.             cout << arr[i] << (i == num ? '\n':' ');
  45.         }
  46. /*
  47.         brr[0] = arr[0];
  48.  
  49.         for(ll i = 1; i < num; i++){
  50.             brr[i] = brr[i - 1] + arr[i];
  51.         }
  52. */
  53.  
  54.          bool save[1005 * 31];
  55.          memset(save, false, sizeof(save));
  56.  
  57.          vector <ll> vc;
  58.          vc.push_back(0);
  59.  
  60.          bool  check = true;
  61.  
  62.          for(ll i = 1; check && i <= num; i++){
  63.  
  64.              if(save[arr[i]] || (i > 1 && arr[i] <= arr[i - 1]))
  65.                  check = false;
  66.  
  67.              ll siz = vc.size();
  68.  
  69.              for(ll j = 0; j < siz; j++){
  70.                  ll now = vc[j];
  71.  
  72.                  if(!save[now + arr[i]]){
  73.                      vc.push_back(now + arr[i]);
  74.                      save[now + arr[i]] = true;
  75.                  }
  76.              }
  77.          }
  78.  
  79.         if(check)
  80.             cout << "This is an A-sequence." << endl;
  81.         else
  82.             cout << "This is not an A-sequence." << endl;
  83.  
  84.     }
  85.  
  86.     return 0;
  87. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top