daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Feb 22nd, 2019 64 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 200005
  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.  
  27. ll gcd(ll a,ll b){ if(b == 0) return a; return gcd(b, a % b); }
  28. ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
  29.  
  30.  
  31. int main()
  32. {
  33.     ll tc, num, t = 1, pownum;
  34.  
  35.     // freopen("/opt/Coding/clion code/input.txt", "r", stdin);
  36.     // freopen("/opt/Coding/clion code/output.txt", "w", stdout);
  37.  
  38.     sc1(num);
  39.  
  40.     ll arr[num + 5], even[num + 5], odd[num + 5];
  41.  
  42.     memset(arr, 0, sizeof(arr));
  43.     memset(even, 0, sizeof(even));
  44.     memset(odd, 0, sizeof(odd));
  45.  
  46.     for(ll i = 1;  i <= num; i++){
  47.          sc1(arr[i]);
  48.          even[i] = even[i - 1];
  49.          odd[i] = odd[i - 1];
  50.  
  51.          if(i & 1) odd[i] += arr[i];
  52.          else even[i] += arr[i];
  53.     }
  54.  
  55.     ll evenans = 0, oddans = 0, cnt = 0;
  56.  
  57.     for(ll i = 1; i <= num; i++){
  58.  
  59.         evenans = even[i - 1];
  60.         oddans = odd[i - 1];
  61.  
  62.         evenans += odd[num] - odd[i];
  63.         oddans += even[num] - even[i];
  64.  
  65.        // cout << evenans << " " << oddans << endl;
  66.  
  67.         if(evenans == oddans) cnt++;
  68.  
  69.     }
  70.  
  71.     pf1(cnt);
  72.  
  73.     return 0;
  74. }
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