View Code of Problem 18

#include <stdio.h>
using namespace std;
int main(){
	
	int n;
	while( ~scanf("%d", &n )){
		if( n==1 || n==2 ){
			printf("0\n");
		}else{
			int k=1;
			int sum = 1;
			for( int i=3; i<n; i++ ){
				if( i%2 == 0 ){
					k++;
				}
				sum +=  k; 
			}
			printf("%d\n", sum); 
			
		}
	} 

	return 0;
	
}

Double click to view unformatted code.


Back to problem 18