SGU-135Drawing Lines
Time Limit: 250MS |
|
Memory Limit: 4096KB |
|
64bit IO Format: %i64d &%i64u |
Submit Status Description Little Johnny likes to draw a lot. A few days ago he painted lots of straight lines in his sheet of paper. Then he counted on how many zones the sheet of paper is split by these lines. He noticed that this number was not always the same. For instance, if he draws 2 lines, the sheet of paper could is split into 4, 3 or even 2 3> (if the lines is identical) zones. Since He's a very curious kid, he would like to know which are the maximum number of zones into which he can split the she Et of paper, if he draws N lines. The sheet of paper is to be considered a very large (=infinite) rectangle. Input The input file would contain an integer number: N (0<=n<=65535). Output You should output one integer:the maximum number of zones to which the sheet of paper can be split if Johnny draws N lines. Sample Input #1 0
Sample Output #1 1
Sample Input #2 1
Sample Output #2 2
Author |
: Mugurel Ionut Andreica |
Resource |
: Ssu::online contester Fall Contest #2 |
Date |
: Fall 2002 |
Source |
is also a mathematical problem, to find the regular.
Rule: 1,2,4,7,11,16 ... A (n) = N (n+1)/2+1; (n starting from 0)
AC Code:
Sgu-135-drawing Lines (simple math!) )