Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
不要打表 给你看看我的代码 216K 0ms 229B的(简单的数学计算)In Reply To:呵呵,打了个小表,有点遗憾啊,虽然过了 Posted by:kirsten0302 at 2009-08-03 18:25:11 #include<iostream> #include<math.h> using namespace std; int main() { int k,m,n; while(cin>>n&&n) { k=sqrt(double(2)*n+0.25)-0.5; m=n-k*(k+1)/2; cout<<n<<' '<<m*(k+1)+k*(k+1)*(2*k+1)/6<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator