fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define pii pair<int,int>
  5. #define fi first
  6. #define se second
  7. #define pb push_back
  8. #define sz size()
  9. #define faster() ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  10. #define vi vector<int>
  11. #define vll vector<ll>
  12. #define vs vector<string>
  13. #define PI 3.141592653589793238
  14. //C:\Users\Public\cpp_learning\input.txt
  15. int main()
  16. {
  17. int n; cin >> n;
  18. ll s = 0;
  19. for (ll i=1; i<=n; i++)
  20. {
  21. s += (pow(-1, i+1) * i);
  22. }
  23. cout << s;
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Standard output is empty