野生小卒 @ 2017-04-30 12:42:26
#include<iostream> using namespace std;main(){int k,g=1,tg=0,i=0;cin>>k;while(1)if((k-i)>=g)tg+=g*g,i+=g,g++;else{tg+=g*(k-i);break;}cout<<tg<<endl;}
by 览遍千秋 @ 2017-08-06 17:03:12