首页 > 其他 > 详细

BEGIN-2 序列求和

时间:2020-04-15 16:13:00      阅读:58      评论:0      收藏:0      [点我收藏+]
  • 等差序列:使用通向公式sum=n*(n+1)/2;
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
const int N=1e5+9;
#define line ‘\n‘
#define gt getchar()
#define mid ((L+R)>>1)
int read(){int x=0,op=1;char c=gt;while(!isdigit(c)){if(c==‘-‘)op=-1;c=gt;}while(isdigit(c))x=x*10+c-48,c=gt;return x*op;}
int main()
{
	int n=read();
	cout<<1LL*n*(n+1)/2<<line; 
	return 0;
}

BEGIN-2 序列求和

原文:https://www.cnblogs.com/ZeroOne-World/p/12706002.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!