gdfz02sjy @ 2023-12-01 18:24:09
#include<bits/stdc++.h>
using namespace std;
long long a,b=0,c=0,d;
int main(){
cin>>a;
for(int i=1;i==i;i++){
for(int j=1;j<i;j++){
b+=j;
c++;
if(c==a){
cout<<b;
return 0;
}
}
}
return 0;
}
by Cl41Mi5deeD @ 2023-12-01 18:29:53
#include<bits/stdc++.h>
using namespace std;
long long a,b=0,c=0,d;
int main(){
cin>>a;
for(int i=1;i==i;i++){
for(int j=1;j<=i;j++){
b+=i;
c++;
if(c==a){
cout<<b;
return 0;
}
}
}
return 0;
}
注意审题
by sunyiming0617 @ 2023-12-01 19:06:37
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b=0,c=1,i;
cin>>a;
for(i=1;i<=a;i++)
a-=i,b+=c*c,c++;
cout<<b+a*c;
return 0;
}
by xxgirlxx @ 2023-12-01 19:19:35
是+i不是+j
by chrisDLkk @ 2023-12-05 15:45:35
}```cpp
using namespace std; int n;int i=1,ans=0,k=0; int main(){ cin>>n;
while(n>0){
n-=i;i++;
k++;
}
//cout<<k<<endl;cout<<(k*(k+1))/2<<endl;
//cout<<n<<endl;
for(int i=1;i<=k;i++){
ans=ans+i*i;
}
ans=ans+n*(i-1);
cout<<ans<<endl;
return 0;
looook at it