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 Ninclusive.

Sample

input output
  1. -3
  1. -5
Problem Source: 2000-2001 ACM Northeastern European Regional Programming Contest (test tour)
  1. // Ural Problem 1068. Sum
  2. // Verdict: Accepted
  3. // Submission Date: 23:26:08 14 Jan 2014
  4. // Run Time: 0.015s
  5. //
  6. // 版权所有(C)acutus (mail: acutus@126.com)
  7. // 博客地址:http://www.cnblogs.com/acutus/
  8. // [解题方法]
  9. // 简单题,直接计算,注意N为负值
  10.  
  11. #include<stdio.h>
  12.  
  13. void solve()
  14. {
  15. int N;
  16. scanf("%d", &N);
  17. if(N ==) {
  18. printf("1\n");
  19. return;
  20. }
  21. if(N % ) {
  22. printf("%d\n",(N > ? ((N + )/ * N) : (- * (- * N + )/ * (- * N) + )));
  23. } else {
  24. printf("%d\n", (N > ? (N/ * (N + )) : (- * (- * N)/ * (- * N + ) + )));
  25. }
  26. }
  27.  
  28. int main()
  29. {
  30. solve();
  31. return ;
  32. }

Ural 1068 - Sum的更多相关文章

  1. URAL 1658. Sum of Digits(DP)

    题目链接 隔了一年零三个月,重新刷URAL,这题挺麻烦的输出路径.输出路径挺扯的,乱写了写乱改改就A了...我本来想用很靠谱,记录每一条路径的,然后输出最小的,结果Tle,然后我使劲水水又过了一组,发 ...

  2. URAL 1658 Sum of Digits

    URAL 1658 思路: dp+记录路径 状态:dp[i][j]表示s1为i,s2为j的最小位数 初始状态:dp[0][0]=0 状态转移:dp[i][j]=min(dp[i-k][j-k*k]+1 ...

  3. 最大子矩阵和 URAL 1146 Maximum Sum

    题目传送门 /* 最大子矩阵和:把二维降到一维,即把列压缩:然后看是否满足最大连续子序列: 好像之前做过,没印象了,看来做过的题目要经常看看:) */ #include <cstdio> ...

  4. Ural 1248 Sequence Sum 题解

    目录 Ural 1248 Sequence Sum 题解 题意 题解 程序 Ural 1248 Sequence Sum 题解 题意 给定\(n\)个用科学计数法表示的实数\((10^{-100}\s ...

  5. ural 1146. Maximum Sum

    1146. Maximum Sum Time limit: 0.5 secondMemory limit: 64 MB Given a 2-dimensional array of positive ...

  6. URAL 1146 Maximum Sum(DP)

    Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the large ...

  7. URAL 1146 Maximum Sum & HDU 1081 To The Max (DP)

    点我看题目 题意 : 给你一个n*n的矩阵,让你找一个子矩阵要求和最大. 思路 : 这个题都看了好多天了,一直不会做,今天娅楠美女给讲了,要转化成一维的,也就是说每一列存的是前几列的和,也就是说 0 ...

  8. URAL 1146 Maximum Sum(最大子矩阵的和 DP)

    Maximum Sum 大意:给你一个n*n的矩阵,求最大的子矩阵的和是多少. 思路:最開始我想的是预处理矩阵,遍历子矩阵的端点,发现复杂度是O(n^4).就不知道该怎么办了.问了一下,是压缩矩阵,转 ...

  9. URAL 1146 Maximum Sum 最大子矩阵和

    题目:click here #include <bits/stdc++.h> using namespace std; typedef unsigned long long ll; con ...

随机推荐

  1. 修改html很实用的insertAdjacentHTML方法

    添加HTML内容与文本内容以前用的是innerHTML与innerText方法, 最近发现还有insertAdjacentHTML和 insertAdjacentText方法, 这两个方法更灵活,可以 ...

  2. QT全局热键(用nativeKeycode封装API,不跨平台)

    在网上找了很长时间,大家都提到了一个QT全局热键库(qxtglobalshortcut),支持跨平台.在这篇文章中,我将只展示出windows平台下全局热键的设置. 这里提供的方法是在MyGlobal ...

  3. AssetManager中的路径参数不能包含"assets/"

    String path = “music/bg.mp3”: //正确的参数 //String path = “assets/music/bg.mp3”: //错误的参数 //String path = ...

  4. js 获取前天、昨天、今天、明天、后天的时间

    js 获取前天.昨天.今天.明天.后天的时间 2011-05-19 21:03   <html><head><meta http-equiv="Content- ...

  5. centos 安装 erlang

    1.首先下载erlang 安装源文件 可以在官网上下载 : http://www.erlang.org/   官网上提供多个版本:   2.下载完成后将R16B01 Source File对应的 ot ...

  6. 五毛的cocos2d-x学习笔记02-基本项目源码分析

    class AppDelegate : private cocos2d::Application private表示私有继承,cocs2d是一个命名空间.私有继承下,Application类中的pri ...

  7. Java中 hashCode()方法详解

    先来看下Object源码里hashcode方法: /**     * Returns a hash code value for the object. This method is      * s ...

  8. 【c语言】求最大值

    一.我个人觉得求最大值比较简单的一种方法(当然同时求最大值和最小值时稍微改改也能行) #include <stdio.h> int main(void) { int f, i, max; ...

  9. Qt Creator error: LNK1123: 转换到 COFF 期间失败: 文件无效或损坏

    Qt Creator error: LNK1123: 转换到 COFF 期间失败: 文件无效或损坏   治标又治本的解决方法:   找到在 { C:\Windows\Microsoft.NET\Fra ...

  10. C# 计算器 如果设置键盘输入的监听事件

    这个事情困扰了我好久,之前java写的计算器程序可以正常运行了,但是因为打包问题(尝试过多次,感觉好麻烦,个人比较崇尚“点子”,注重创新,思来想去之后,决定试试C#模仿java再写一遍),想要用C#模 ...