Ural-1068. Sum(水题)
来源:互联网 发布:电脑便签软件 编辑:程序博客网 时间:2024/05/22 14:11
1068. Sum
Time limit: 2.0 secondMemory limit: 64 MBYour 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 Ninclusive.Sample
input output -3
-5
题意:计算1-N的和
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <vector>#include <map>#include <set>#include <algorithm>using namespace std;int n,sum;int main(){// freopen("in.txt","r",stdin); while(scanf("%d",&n)!=EOF) { sum = 0; if(n<0) { sum = (n-1)*(-n)/2; sum++; } else if(n>1) { sum = (n+1)*n/2; }else { sum = 1; } printf("%d\n",sum); } return 0;}
- Ural-1068. Sum(水题)
- URAL 1068. Sum
- URAL 1068. Sum (小学数学题)
- Ural 1146. Maximum Sum
- Ural 1068 - Sum
- Ural 1068 sum
- URAL 1146. Maximum Sum
- Ural 1146 Maximum Sum
- Ural 1658 Sum of Digits
- ural 1658. Sum of Digits
- Ural acm 1146. Maximum Sum
- URAL 1658. Sum of Digits
- Ural 1658 Sum of Digits
- ural 1146. Maximum Sum dp
- 1146. Maximum Sum URAL 解题报告
- Ural 1146. Maximum Sum DP经典
- URAL 1658. Sum of Digits(简单dp)
- URAL 1749 Periodic Sum (二分法 + 溢出处理)
- QTP错误处理机制
- sql plus修改用户名和密码-orcale 11g修改用户名和口令的方法
- VBScript类型转换函数
- VBScript数组函数
- 黑马程序员---关于JAVA中JDK1.5新特性
- Ural-1068. Sum(水题)
- Emacs配置记录
- 百度SEO与谷歌SEO的10大区别
- Java乔晓松-android中的Tween动画的使用
- arcgis入门到精通视频教程下载连接
- DFS 对一系列给定数据 进行深度优先遍历 获得54321的所有可能组合
- win7 OrCAD Capture 找不到MSVCR90.dll
- Linux网络安装介绍1
- Win7 线程语言设置错误可能引起窗口排版变化