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

Re:真是服了 cout 和printf换换样就不对了 c++又不支持cout<<了吗?真是的

Posted by 1108060046 at 2012-07-20 18:06:00 on Problem 2000
In Reply To:真是服了 cout 和printf换换样就不对了 c++又不支持cout<<了吗?真是的 Posted by:0712105003 at 2009-10-16 14:25:20
#include<stdio.h>
int main()
{
  int n;
  int i=0;
  int sum,count;
  int result;
  while(scanf("%d",&n)!=EOF)
  {   
	  i=0;
	  sum=0;
	  count=0;
	  if(n==0) break;
	  do
	  {
		  i++;
		  sum+=i;
		  count+=i*i;
		  if(sum==n)
		  {
			 result=count;
		  }
		  else
			 result=count+(n-sum)*i;
	  }while(sum<n);
	  printf("%d %d\n",n,result);
  }
        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