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 |
靠 如此简单一题 高精度都不要!!!#include<stdio.h> int fun2(int n) { return n*(n+1)/2; } int fun(int m) { int n,i; for(i=1;i<=m;i++) //控制 m 范围 { if(m>=fun2(i)&&m<fun2(i+1)) { n=i;break; } } return n; } __int64 fun3(int m,int n) { return n*(n+1)*(2*n+1)/6+(m-n*(n+1)/2)*(n+1); //return n*(m-n/3-(n*n/6)); } int main() { int m; while(scanf("%d",&m)!=EOF) { if(m==0)break; printf("%d %I64d\n",m,fun3(m,fun(m))); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator