题解 | 小乐乐求和
小乐乐求和
https://www.nowcoder.com/practice/ce0b2eacd3d04647831358c2876e44ff
#include<bits/stdc++.h>
using namespace std;
const int N=1e9+2;
typedef long long ll;
ll a[N];
void solve()
{
ll n;cin>>n;//得开long long 因为结果会超1e9
cout<<(1+n)*n/2<<'\n';
}
int main()
{ ios::sync_with_stdio(false);
cin.tie(nullptr);
int t=1;
while(t--)
{
solve();
}
return 0;
}
查看10道真题和解析