Calarence4 @ 2023-07-26 23:55:08
#include<bits/stdc++.h>
using namespace std;
int k,n,i=1;
unsigned long long *a;
int main()
{
cin>>k;
n=k;
a=new unsigned long long [k+5];
while(n)
{
for(int j=1;j<=i;j++)
{
a[k-n+1]=a[k-n]+i;
n--;
}
i++;
}
cout<<a[k];
return 0;
}
by wyf1202 @ 2023-07-27 00:37:40
《为什么要用指针》
by Weizhuo_Zhao @ 2023-07-27 08:19:59
你最好开数组10005
by wbhqm @ 2023-07-27 11:10:18
#include<iostream>
using namespace std;
int main()
{
int k,b=0,c=1;
cin>>k;
while(k)
{
for(int i=c;i>0;i--)
{
b+=c;
k--;
if(k==0)
{
break;
}
}
c++;
}
cout<<b;
return 0;
}
AC代码,看一下
by lovely_fcukh @ 2023-07-27 18:05:26
@a3325913526 你的问题很明显,你犯了一下几条错误:
我改了一下你的代码A了:
#include<bits/stdc++.h>
using namespace std;
int k,n,i=1;
unsigned long long *a;
int main()
{
cin>>k;
n=k;
a=new unsigned long long [k+1145];
memset(a,0,sizeof a);
while(n>0)
{
for(int j=1;j<=i;j++)
{
a[k-n+1]=a[k-n]+i;
n--;
}
i++;
}
cout<<a[k];
return 0;
}
by Identity__V @ 2023-08-10 09:43:26
这样编
(不简单吗)
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k,t=0,s=0;
cin>>k;
for(int i=1;;i++)
for(int j=1;j<=i;j++)
{t+=i;
s++;
if(s==k)
{cout<<t;
return 0;
}
}
return 0;
}
大佬勿喷求求了!
by zhanghe724_1 @ 2023-08-12 13:16:26
史上最诡异的循环
#include<iostream>
using namespace std;
int main(){
int n,s=0;
cin>>n;
for(int i=1;i=i;i++){
if(n){
if(n>i){
n-=i;
s+=i*i;
}
else{
s+=n*i;
n=0;
}
continue;
}
break;
}
cout<<s;
}