fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4. int n;
  5. cin>>n;
  6. long long s=0;
  7. for(int i=0;i<=n;i++){
  8. s=s+pow(-1,i+1)*i;
  9. }
  10. cout<<s;
  11. }
  12.  
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
10936