| ||||||||||
| 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 | |||||||||
Re:平方和公式犀利In Reply To:平方和公式犀利 Posted by:hustcswgy at 2011-07-27 17:59:27 > #include<stdio.h>
>
> int main()
> {
> int day;
> while(scanf("%d", &day), day)
> {
> int n = 1;
> while((1+n)*n/2 < day) n++;
> printf("%d %ld\n", day, (n-1)*n*(2*n-1)/6 + n*(day-(n-1)*n/2));
> }
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator