Submit | All submissions | Best solutions | Back to list |
BISHOPS - 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./p>
Sam's chessboard has size N × 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 positive integer N representing the size of the i-th chessboard. [1 ≤ N ≤ 10100]
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 |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | IPSC 2004 |
hide comments
|
||||||||||||||
2013-07-22 21:02:07 Viktor Fonic
One line with 69 characters in ruby :) |
||||||||||||||
2013-06-22 06:33:52 Raman Shukla
For reading End of input use Try except in Python... |
||||||||||||||
2013-05-25 18:25:04 Devashish Mathur
how to find last input using python..?? |
||||||||||||||
2013-05-18 05:34:38 ankita
how is end of file detected in python? |
||||||||||||||
2013-05-15 14:25:54 Juraj Dudak
@zonker yeah, python rocks.. my solution has 2 lines ;) and the first one is import sys |
||||||||||||||
2013-05-09 20:56:59 zonker
best code I ever wrote... 9 lines in python.. python big rocks!! |
||||||||||||||
2013-03-13 11:47:51 Harsh Gupta
Such a huge input size N <= 10^100 C is no!!! |
||||||||||||||
2013-03-09 10:07:46 alampata
can anyone tell me how to end input in C? |
||||||||||||||
2013-02-27 19:41:49 reggaeguitar
I used this in Java and got ac Scanner in = new Scanner(System.in); while(in.hasNextBigInteger()) { //code } |
||||||||||||||
2013-02-16 11:01:01 Ashish
Finally AC.... After 4 WA... phewww |