YTU 2905: The Sum of 1...N

网友投稿 274 2022-09-15

YTU 2905: The Sum of 1...N

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 using namespace std;int main(){ unsigned long long n; int T; cin>>T; while(T--) { cin>>n; n=n*(n+1)/2; cout<

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:视频号加速更新:朋友圈广告可跳转到视频号,实例解析来了!
下一篇:YTU 2851: 数字游戏
相关文章

 发表评论

暂时没有评论,来抢沙发吧~