SGU-135-Drawing Lines (simple mathematics !)

Source: Internet
Author: User

SGU-135-Drawing Lines (simple mathematics !)

SGU-135 Drawing Lines
Time Limit:250 MS 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 on his sheet of paper. then he counted in how many zones the sheet of paper was split by these lines. he noticed that this number is not always the same. for instance, if he draws2Lines, the sheet of paper cocould be split4,3Or even2(If the lines are identical) zones. since he is a very curious kid, he wowould like to know which is the maximum number of zones into which he can split the sheet of paper, if he drawsNLines. The sheet of paper is to be considered a very large (= infinite) rectangle.

Input

The input file will contain an integer number:N(0 <= N <= 65535).

Output

You shoshould output one integer: the maximum number of zones into which the sheet of paper can be split if Johnny drawsNLines.

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



It is also a mathematical problem ..


Rule: 1, 2, 4, 7, 11, 16... a (n) = n * (n + 1)/2 + 1; (n starts from 0)


AC code:


#include 
 
  #include 
  
   #include #include 
   
    #include 
    
     #include 
     
      using namespace std;int main(){int n;scanf("%d", &n);printf("%d\n", (int)((long long)n*(n+1)/2+1)); return 0;} 
     
    
   
  
 


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.