Ural 1068 sum
2014-08-07 09:07
369 查看
A -
Sum(1.5.1)
Crawling in process...
Crawling failed
Time Limit:2000MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Your task is to find the sum of all integer numbers lying between 1 and
N inclusive.
Input
The input consists of a single integer N that is not greater than 10000 by it's absolute value.
Output
Write a single integer number that is the sum of all integer numbers lying between 1 and
N inclusive.
Sample Input
题目大意:
求出1到N的和
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int sum=0;
int i;
if(n<1)
for(i=n;i<=1;i++)
sum=sum+i;
if(n>=1)
for(i=1;i<=n;i++)
sum=sum+i;
cout<<sum<<endl;
return 0;
}
Sum(1.5.1)
Crawling in process...
Crawling failed
Time Limit:2000MS
Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Your task is to find the sum of all integer numbers lying between 1 and
N inclusive.
Input
The input consists of a single integer N that is not greater than 10000 by it's absolute value.
Output
Write a single integer number that is the sum of all integer numbers lying between 1 and
N inclusive.
Sample Input
input | output |
---|---|
-3 | -5 |
求出1到N的和
#include <iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int sum=0;
int i;
if(n<1)
for(i=n;i<=1;i++)
sum=sum+i;
if(n>=1)
for(i=1;i<=n;i++)
sum=sum+i;
cout<<sum<<endl;
return 0;
}
相关文章推荐
- Ural 1068 - Sum
- Ural 1068 - Sum
- (datastructure1.5.1)URAL 1068 SUM(计算前n项和)
- URAL 1146 Maximum Sum & HDU 1081 To The Max (DP)
- URAL 1206 Sum of Digits of the Sum of Numbers
- URAL 1021 Sacrament of the Sum
- ural 1146. Maximum Sum dp
- 1068. Sum Time limit
- URAL1658 Sum of Digits(DP)
- UVA-1068 Sum-1-N之间所有数的和
- POJ 2366 (URAL 1021)Sacrament of the Sum
- URAL 1021 Sacrament of the Sum
- Ural 1658 Sum of Digits
- Ural 1068
- Ural 1658 Sum of Digits
- POJ 2785 4 Values whose Sum is 0 二分
- LeetCode之“树”:Sum Root to Leaf Numbers
- a1007 . Maximum Subsequence Sum (25)
- ural 1101(Robot in the Field )表达式求值
- URAL 1023 Buttons 博弈