Sphere Online Judge

Computer geeks! Show off your skills and claim the job of your dreams! RecruitCoders.com

SPOJ Problem Set (classical)

328. Bishops

Problem code: BISHOPS

Yesterday was Sam's birthday. The most interesting gift was definitely the chessboard. Sam quickly learned the rules of chess and defeated his father, all his friends, his little sister, and now no one wants to play with him any more.

So he decided to play with another birthday gift – a Book of Math Problems for Young Mathematicians. He opened the book somewhere in the middle and read the following problem: "How many knights can be placed on a chessboard without threatening each other?" After 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?". Sam is in trouble here. He is not able to solve this problem and needs your help.

Sam'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

The input file consists of several lines. The line number i contains a single number N representing the size of the i-th chessboard. [N <= 10^100]

Output

The output file should contain the same number of lines as the input file. The i-th line should contain one number – the maximum number of bishops that can be placed on i-th chessboard without threatening each other.

Example

Input:
2
3

Output:
2
4


Added by:Roman Sol
Date:2005-04-17
Time limit:1s
Source limit:10000B
Languages:All
Resource:IPSC 2004

hide comments
2012-02-27 08:44:40 Hamza7
finally got AC .. the catch lies in the fact that inputs are relatively large nd for input case 1 ans should be 1 ( weird though as they even consider 1X1 a chessboard !!)
2012-02-05 06:08:07 yuvaraja
using long multiplication gives me TLE....any one can help...???
2012-01-24 03:48:47 Prashant Golash
Hi, I wanted to know when to stop reading input, as it has been mentioned several numbers.
2011-12-12 13:22:44 Aditya Muttur
what does "from itertools import imap" do?
2011-12-05 22:09:28 HK
I think my logic is correct but i keep getting wrong answer
my problem id is: 6136088
can u help me here
2011-09-10 18:53:29 cool


Last edit: 2011-09-19 13:54:37
2009-11-25 03:32:31 Jesús Gómez
7 lines in Python, and includes a "from itertools import imap"
2009-11-19 07:53:50 Daniel Ampuero
A bishop is the one that moves diagonally :D
2011-10-17 19:46:33 Shahriar Ameri
The input specification is the challenge to this problem ...
SPOJ System © 2012 Sphere Research Labs | Projekty informatyczne i aplikacje na zamówienie. All Rights Reserved.