Home Alone Yet Again!!!



Home Alone Yet Again!!!

The Home Alone kid Kevin is again accidentally left home alone by his family. 

                                                                                                                              

This time the troublemaker Kevin has no thieves to set his intelligent baits and trap them. 

                                                                              

It was just fun, frolic, eating pizzas all to himself, jumping on his parents' bed, and making a mess. 

                                                                       

And to this list is surprisingly a serious task to learn some tricky Chess moves that he would use to defeat his sister and brother and win over the pack of Marshmellows. 

                                                                                                                         
  
To improvise his skills on Chess, Kevin attempted to read through a book which challenged him with numerous problems on Chess. He came across one such problem which read: "How many knights can be placed on a chessboard without threatening each other?" After thinking deep for a while, he realized that this was trivial and moved on to the next problem: "How many bishops can be placed on a chessboard without threatening each other?". Kevin is in trouble here. He is not able to solve this problem and needs your help. 

                                                                                                              
  
Kevin's chessboard has size N x N. A bishop can move to any distance in any of the four diagonal directions. A bishop threatens another bishop if it can move to the other bishop's position. Your task is to compute the maximum number of bishops that can be placed on a chessboard in such a way that no two bishops threaten each other. 
  
Input Format : 
Input contains a single positive integer N representing the size of the i-th chessboard. [1 <= N <= 10^6] 
  
Output Format : 
Output consists of an integer that corresponds to the maximum number of bishops that can be placed on i-th chessboard without threatening each other. 
Refer sample input and output for formatting specifications. 

Sample Input 1: 
2 
Sample Output 1: 
2 
  
Sample Input 2: 
3 
Sample Output 2: 
4 


#include < stdio.h >
#include < stdlib.h >
int main()
{
int n;
scanf("%d",&n);
printf("%d",(2*(n-1)));

if(n < 1)
exit(0);
return 0;

}

No comments: