Get The Sum
来源:互联网 发布:java p2p项目视频下载 编辑:程序博客网 时间:2024/05/21 12:48
Get The Sum
Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^
题目描述
Now you have got an task of calculating the sum of integers between 1 and N inclusively.
输入
The first line of input is an integer T (0 < T ≤ 100),which means there are T test cases.The next following T lines contains T integers,each in a separate line.The absolute value of N is no more than 10000.
输出
For each test case,output the sum of integers between 1 and N inclusively.
示例输入
312-3
示例输出
13-5
提示
来源
示例程序
#include<stdio.h> int main() { int i,j,n,m,a[100]; scanf("%d",&n); for(i=0;i<n;i++) { m=0; scanf("%d",&a[i]); if(a[i]>0) for(j=a[i];j>=1;j--) { m+=j; } else for(j=a[i];j<=1;j++) { m+=j; } printf("%d\n",m); } }
0 0
- Get The Sum
- leetcode c++ get combination sum
- how can i get [5, 7, 13, 2] to go to [5*0, 7*1, 13*2, 2*3] then get the sum of this array.
- [SGU]123. The sum
- sgu 123 The sum
- HDOJ2058 The sum problem
- HDU2058:The sum problem
- Sgu 123. The sum
- sgu 123 The sum
- The sum problem
- The sum problem
- 2058 The sum problem
- hdoj2058 The sum problem
- sgu123:The sum
- The sum problem 2058
- The sum problem
- Has the sum exceeded
- The partial sum problem
- CentOS6.5 安装 OpenFOAM-2.4.0
- mybatis #与$的区别
- 从 NSURLConnection 到 NSURLSession
- Android命名规范
- 几种常用的设计模式介绍
- Get The Sum
- 摩尔斯电码快速记忆
- Dalvik和ART的区别
- 纹理相关知识整理
- dbi 句柄
- android studio 使用大全
- FMDB基本用法及图片选择器
- 让切换目录更方便: pushd, popd, dirs, cd -
- iOS 【错误:unrecognized selector sent to instance 0x7aa552b0】