linyuqikimi @ 2022-05-08 09:33:27
#include<bits/stdc++.h>
using namespace std;
int main() {
long long k,m,n;
cin>>k;
for(int i=1;i<=k;i++){
for(int j=1;j<=i;j++){
n=i+j;
m=m+n;
}
}
cout<<k;
return 0;
}
救救孩子吧
by _Haoomff_ @ 2022-05-08 09:34:39
@linyuqikimi 输出要在循环里特判
by linyuqikimi @ 2022-05-08 09:35:02
@Haoomff 怎么搞
by _Haoomff_ @ 2022-05-08 09:38:33
@linyuqikimi 稍微改得多了一些哈,别介意
#include<bits/stdc++.h>
using namespace std;
int main() {
long long k,m=0,n=0;
cin>>k;
for(int i=1;i<=k;i++){
for(int j=1;j<=i;j++){
n++;
m+=i;
if(n==k){
cout<<m;
return 0;
}
}
}
return 0;
}
by linyuqikimi @ 2022-05-08 09:39:24
@Haoomff 栓Q