小 (→摘要: 格式) |
小 (→题解: 加入题解) |
||
| 第9行: | 第9行: | ||
==题解== | ==题解== | ||
*作为一道A+B类似物居然又WA了……原因是每个数据之后要两个换行,还有过程中可能会爆int要用64位。 | *作为一道A+B类似物居然又WA了……原因是每个数据之后要两个换行,还有过程中可能会爆int要用64位。 | ||
| + | *做法么,O(n)的不知道可不可以,反正可以用个公式么:<m>a_n=\frac{n*(n+1)}{2}</m> | ||
| + | |||
==代码== | ==代码== | ||
{{折叠|1001.cpp代码已折叠 | {{折叠|1001.cpp代码已折叠 | ||
| 题目链接 | 难度等级 | 完成状态 | 完成分数 | 最后编辑时间 | 失误原因(初次提交分数) |
|---|---|---|---|---|---|
| Sum Problem | ★☆☆☆☆ | 答案正确 | 100 | 2015-02-06 10:30:54 | 输出格式(0) |
求1+2+...+n。
| 1001.cpp代码已折叠
展开折叠内容
|
|---|
#include<iostream>
using namespace std;
int main()
{
unsigned long long a;//fixed:using ull//
while(cin>>a)
{
unsigned long long t=(a+1)*a>>1;
cout<<t<<endl<<endl;//fixed:endl//
}
return 0;
}
|