首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >ACMSGURU 135 - Drawing Lines

ACMSGURU 135 - Drawing Lines

作者头像
Reck Zhang
发布2021-08-11 10:51:23
发布2021-08-11 10:51:23
4070
举报
文章被收录于专栏:Reck ZhangReck Zhang

Drawing Lines

Problem 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 draws 2 lines, the sheet of paper could be split into 4, 3 or even 2 (if the lines are identical) zones. Since he is a very curious kid, he would like to know which is the maximum number of zones into which he can split the sheet of paper, if he draws N lines. 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 should output one integer: the maximum number of zones into 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

Solution

代码语言:javascript
复制
#include <bits/stdc++.h>

int main() {
    std::ios::sync_with_stdio(false);

    unsigned long long x;
    std::cin >> x;

    std::cout << 1 + x * (x + 1) / 2 << std::endl;
    return 0;
}
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-12-17,如有侵权请联系 cloudcommunity@tencent.com 删除
目录
  • Drawing Lines
    • Problem Description
    • Input
    • Output
    • Sample Input #1
    • Sample Output #1
    • Sample Input #2
    • Sample Output #2
    • Solution
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档