View Code of Problem 18

#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int a[100100];
	a[1]=0;a[2]=0;a[3]=1;a[4]=2;
	for(int i=5;i<100100;++i){
		a[i]=a[i-2]+i-2;
	}
	int x;
	while(cin>>x&&x!=EOF){
		cout<<a[x]<<endl;
	}
}

Double click to view unformatted code.


Back to problem 18