Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- #ifndef ONLINE_JUDGE
- freopen("input.txt","r",stdin);
- freopen("out.txt","w",stdout);
- #endif
- int n, sum=0;
- cin>>n;
- if(n%2==0)
- {
- n = n-1;
- int mid = ceil(n/2.0);
- int OneSum = n+1;
- int totalPair = floor(OneSum/4);
- if(mid%2!=0)
- {
- sum = (OneSum*totalPair)+mid;
- }
- else sum = (OneSum*totalPair);
- }
- else
- {
- int mid = ceil(n/2.0);
- int OneSum = n+1;
- int totalPair = floor(OneSum/4);
- if(mid%2!=0)
- {
- sum = (OneSum*totalPair)+mid;
- }
- else sum = (OneSum*totalPair);
- }
- cout<<sum<<endl;
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement