2905: The Sum of 1...N

时间限制: 1 Sec  内存限制: 128 MB

提交: 281  解决: 51

题目描述

Given an integer n,your task is to calculate 1+2+...+N;

输入

The first line of input contains an integer T, indicating the number of test cases (T<=20)

The each test case contains a single positive integer N(N<=2^32).

输出

For each input you should output the sum of 1+2+...+N in one line.(The result must less than 2^63)

样例输入

2101

样例输出

551

im0qianqian_站在回忆的河边看着摇晃的渡船终年无声地摆渡,它们就这样安静地画下黄昏画下清晨......

#include <iostream>
using namespace std;
int main()
{
unsigned long long n;
int T;
cin>>T;
while(T--)
{
cin>>n;
n=n*(n+1)/2;
cout<<n<<endl;
}
return 0;
}

YTU 2905: The Sum of 1...N的更多相关文章

  1. 如何在web中实现类似excel的表格控件

    Execl功能非常强大,内置的很多函数或公式可以大大提高对数据的加工处理能力.那么在web中有没有类似的控件呢?经过一番搜寻,发现handsontable具备了基本的excel功能支持公式,同时能对数 ...

  2. LeetCode - Two Sum

    Two Sum 題目連結 官網題目說明: 解法: 從給定的一組值內找出第一組兩數相加剛好等於給定的目標值,暴力解很簡單(只會這樣= =),兩個迴圈,只要找到相加的值就跳出. /// <summa ...

  3. Leetcode 笔记 113 - Path Sum II

    题目链接:Path Sum II | LeetCode OJ Given a binary tree and a sum, find all root-to-leaf paths where each ...

  4. Leetcode 笔记 112 - Path Sum

    题目链接:Path Sum | LeetCode OJ Given a binary tree and a sum, determine if the tree has a root-to-leaf ...

  5. POJ 2739. Sum of Consecutive Prime Numbers

    Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050 ...

  6. BZOJ 3944 Sum

    题目链接:Sum 嗯--不要在意--我发这篇博客只是为了保存一下杜教筛的板子的-- 你说你不会杜教筛?有一篇博客写的很好,看完应该就会了-- 这道题就是杜教筛板子题,也没什么好讲的-- 下面贴代码(不 ...

  7. [LeetCode] Path Sum III 二叉树的路径和之三

    You are given a binary tree in which each node contains an integer value. Find the number of paths t ...

  8. [LeetCode] Partition Equal Subset Sum 相同子集和分割

    Given a non-empty array containing only positive integers, find if the array can be partitioned into ...

  9. [LeetCode] Split Array Largest Sum 分割数组的最大值

    Given an array which consists of non-negative integers and an integer m, you can split the array int ...

随机推荐

  1. python 数据库操作产生中文乱码的解决办法

    1.执行python mysql数据库查询操作时,产生中文乱码 #!/usr/bin/python # -*- coding: UTF-8 -*- import MySQLdb db = MySQLd ...

  2. shell实现ftp命令示例

    一.shell脚本示例: [plain] view plaincopy cd /PATH_YOU_WANT_TO_UPLOAD(DOWNLOAD) ftp -niv <<- EOF ope ...

  3. Centos7 中Nginx的安装与配置

    安装与配置 1.安装nginx yum intsall nginxsudo systemctl start nginx 启动服务sudo firewall-cmd --permanent --zone ...

  4. jquery版本的问题造成第二次全选无效

    注意:第一种方式点击全选按钮 第一次全选有用第二次全选无效.因为jquery1.7以上的版本用此方法只能第一次好用,第二次就会失效,用第二种方式解决

  5. XV内存变化

  6. UltraEdit-14.10.0.1024版本语法着色配置

    用了UltraEdit有段时间了,一直没做语法着色,当做普通文本编辑器使用,这也太委屈这个“神器”了. 今天就让它物尽其用吧.体验一把UltraEdit的语法高亮功能. 参考:http://www.1 ...

  7. x1 carbon 扩展屏 模糊

    x1 carbon 扩展屏 模糊,扩展屏是dell的屏,分辨率最大是1920*1080, x1最大是2560*1440. 不论是通过DP mini转VGA,还是HDMI,输出都是模糊,只有复制屏幕的时 ...

  8. mysql 修改管理员密码

    mysql 修改管理员密码 本次学习环境: windows 7系统.mysql 5.7.14. 一.如果是忘记了用户密码: (1).关闭正在运行的MySQL服务. 方法一:可以直接操作wamp软件,左 ...

  9. 登录页面练习servlet

    登录练习: 1创建登录页面 创建servlet进行登录页面请求 2点击登录完成操作 浏览器发送请求到服务器(用户信息+其他数据 )3服务器调用对应的servlet进行处理 设置响应编码格式 获取请求信 ...

  10. Spring Boot中使用logback日志框架

    说明:Spring Boot在最新的版本中默认使用了logback框架.一般来说使用时只需在classpath下创建logback.xml即可,而官方推荐使用logback-spring.xml替代, ...