View Code of Problem 18

#include<iostream>
#include<math.h>
#include<stdio.h>
#include<cstring>
using namespace std;
int main() {
	int n;
	while(cin>>n){
		int h=n/2;
		int sum=(h*(h-1))/2;
		if(n%2==0){
			sum=sum*2;
		}else{
		sum=sum*2+h;
		}
		cout<<sum<<endl;
	}
}

Double click to view unformatted code.


Back to problem 18