#include#includeusing namespace std;int main(){    long long a;    while(cin>> a){        if(a%2 == 0) cout << a/2 * (a+1) << "\n\n";        else cout << (a+1)/2 *a << "\n\n";    }    return            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-08-05 16:31:40
                            
                                26阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            Sum Problem Sample code :            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2017-04-28 09:53:00
                            
                                202阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 480655 Accepted Submission(s): 121603 Problem Desc            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-07-28 10:11:20
                            
                                67阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            /* 注意可以是负整数,而且在过程中会超过int,所以要用longlong*/#include int main(){ long long n; while (scanf("%lld",&n)!=EOF) (n<1)?printf("%d\n\n",(n+1)*(2-n)/2):printf("%d\n\n",n*(n+1)/2); return 0;}            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2014-02-11 19:50:00
                            
                                66阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + … + n.Input The input will consist of a series of int            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-05-14 11:35:17
                            
                                105阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            前n项和 没什么说的 杭电的1001总是...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2015-12-19 17:40:00
                            
                                55阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            #includeint main(){	unsigned int a;	while(scanf("%u",&a)!=EOF)	{			if(a]            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-03-08 07:00:50
                            
                                88阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            Sum ProblemTime Limit: 1000/500 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 113869Accepted Submission(s): 26069Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.In            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2011-07-26 14:28:00
                            
                                57阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            1 #include 2 int main(){ 3 int k,sum; 4 while(scanf("%d",&k)!=EOF){ 5 if(k%2==0){ 6 sum=(1+k)*(k/2); 7 ...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2014-10-26 13:16:00
                            
                                44阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            杭电:1001 Sum Problem java实现Sum ProblemTime Limit: 1000/500 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 623141Accepted Submission(s): 157688Problem De...            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2021-08-28 09:18:55
                            
                                177阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            杭电:1001 Sum Problem java实现Sum ProblemTime Limit: 1000/500 MS (Java/Others)Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 623141Accepted Submission(s): 157688Problem De...            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-03-29 14:28:07
                            
                                123阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            Sum ProblemTime Limit: 1000/500 MS (Java/Others)    Memory Limit: 65536/32768 K (Ja            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-09-26 14:38:58
                            
                                46阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            本文使用 Google Docs 编辑,以网页形式发布。最新版本请看以下链接:
http://docs.google.com/View?id=df4r7psc_971cf4bpgc4
POJ Problem 1001 Solved!
  今晚终于让我的 problem 1001 代码得到 POJ *Accepted* 了。今天早上就写基本写好了,在本机上测试都没有发现问题,但提交时总是 *W            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2010-05-07 22:36:17
                            
                                682阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            先确定一段和sum=m的最长的长度,要最长则起点从1开始,根据等差求和,len*(len+1)/2=m;放缩法则len^2<2*m,所以len=pow(2.0*m,0.5);现在根据长度确定起点L,根据等差求和公式,((len+L-1)+L)*len/2=m; => L=(2*m/len+1-len            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2019-08-09 17:43:00
                            
                                81阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            2018-04-22 19:59:52 Sum系列的问题是Leetcode上的一个很经典的系列题,这里做一个简单的总结。 167. Two Sum II - Input array is sorted 167. Two Sum II - Input array is sorted 问题描述: 问题求            
                
                    
                        
                                                            
                                                                        
                                                                                        转载
                                                                                    
                            2018-04-22 20:56:00
                            
                                87阅读
                            
                                                                                    
                                2评论
                            
                                                 
                 
                
                             
         
            
            
            
            The sum problem
Given a sequence 1,            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2023-05-05 18:14:30
                            
                                39阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            1001: A+B Problem时间限制: 1 Sec  内存限制: 10 MB提交: 4864  解决: 3132[提交][状态][讨论版]题目描述Calculate a+b输入Two integer a,b (0输出Output a+b样例输入1 2样例输出3迷失在幽谷            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-08-10 21:35:26
                            
                                98阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            今天做PAT看见一个特别炫酷的一栏,就做了一道题。。。。A + B ProblemTime Limit: 2000 msMemory Limit: 65536 KBCalculate a + bInputThe input will consist of a series of(原谅我英文不好,没看到这个) pairs of integers a and b,separat...            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2022-03-09 15:28:09
                            
                                49阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            今天做PAT看见一个特别炫酷的一栏,就做了一道题。。。。A + B ProblemTime Limit: 2000 msMemory Limit: 65536 KBCalculate a + bInputThe input will consist of a series of(原谅我英文不好,没看到这个) pairs of integers a and b,separat...            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-07-08 17:10:21
                            
                                151阅读
                            
                                                                             
                 
                
                             
         
            
            
            
            题目描述输入两个整数a,b,输出它们的和(|a|,|b|<=10^9)。 注意pascal使用integer会爆掉哦!有负数哦!c/c++的main函数必须是int类型,而且最后要return 0。这不仅对洛谷其他题目有效,而且也是noip/noi比赛的要求! 好吧,同志们,我们就从这一题开始,向着大牛的路进发。 任何一个伟大的思想,都有一个微不足道的开始。 输入输出格式 输入格...            
                
                    
                        
                                                            
                                                                        
                                                                                        原创
                                                                                    
                            2021-08-26 10:25:00
                            
                                111阅读