Posted on April 28, 2009 by jasperpoj_2000 /* //ACM Poj 2000 //File: 2000.cpp //Author: Kangzj //Mail: Kangzj@mail.bnu.edu.cn //Date: April 24, 2009 */ #include #include #include using namespace std; int main() { int day; int coinDay, coinAll; ostringstream buff; while(1) { cin>>day; if(day==0)break; float temp=sqrt(1+8*day); int tmp=(int)temp; if(temp!=(float)tmp && tmp%2!=0) { tmp+=2; }else if(temp!=(float)tmp && tmp%2==0) { tmp++; }else { tmp=tmp; } coinDay=(-1+tmp)/2; coinDay--; coinAll=coinDay*(coinDay+1)*(2*coinDay+1)/6; coinAll+=(coinDay+1)*(day-(coinDay+1)*coinDay/2); buff< 需要选择G++才能通过,如果想用C++,只要加几个强制转换就可以了。 Share this:FacebookXLike this:Like Loading... Related