高斯的题解|我的题解
2024-09-10 21:52:22
发布于:江苏
11阅读
0回复
0点赞
什么,我竟然没有高斯聪明,瞎说什么
大实话
高斯的题解
#include<bits/stdc++.h>
#define ll long long //防伪标识
#define MAXN 1005
#define maxn 10005
#define MAXM 10000
#define maxm 1000005
#define Y1 "YES"<<endl
#define N1 "NO"<<endl
#define Y2 "yes"<<endl
#define N2 "no"<<endl
#define Y3 "Yes"<<endl
#define N3 "No"<<endl
using namespace std;
ll t;
int main(){
cin>>t;
cout<<(1+t)*t/2;
return 0;
}
我的题解
#include<bits/stdc++.h>
#define ll long long //防伪标识
#define MAXN 1005
#define maxn 10005
#define MAXM 10000
#define maxm 1000005
#define Y1 "YES"<<endl
#define N1 "NO"<<endl
#define Y2 "yes"<<endl
#define N2 "no"<<endl
#define Y3 "Yes"<<endl
#define N3 "No"<<endl
using namespace std;
ll t;
ll sum;
int main(){
cin>>t;
for(int i = 1;i<=t;i++)
sum+=i;
cout<<sum;
return 0;
}
这里空空如也
有帮助,赞一个