Anik_Akash

odd sum

Feb 3rd, 2021
803
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4. int main()
  5. {
  6.    #ifndef ONLINE_JUDGE
  7.        freopen("input.txt","r",stdin);
  8.        freopen("out.txt","w",stdout);
  9.    #endif
  10.    int n, sum=0;
  11.    cin>>n;
  12.    if(n%2==0)
  13.    {
  14.        n = n-1;
  15.        int mid = ceil(n/2.0);
  16.        int OneSum = n+1;
  17.        int totalPair = floor(OneSum/4);
  18.        if(mid%2!=0)
  19.        {
  20.             sum = (OneSum*totalPair)+mid;
  21.        }
  22.        else  sum = (OneSum*totalPair);
  23.  
  24.    }
  25.    else
  26.    {
  27.        int mid = ceil(n/2.0);
  28.        int OneSum = n+1;
  29.        int totalPair = floor(OneSum/4);
  30.        if(mid%2!=0)
  31.        {
  32.             sum = (OneSum*totalPair)+mid;
  33.        }
  34.        else  sum = (OneSum*totalPair);
  35.    }
  36.  
  37.     cout<<sum<<endl;
  38.     return
RAW Paste Data