Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

平方和公式犀利

Posted by hustcswgy at 2011-07-27 17:59:27 on Problem 2000
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator