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

纪念进7000,留代码思路如下

Posted by lijingwei at 2010-08-04 18:15:08 on Problem 2140
#include<iostream>
using namespace std;
int main()
{
	int n,x,count;
	cin>>x;
	count=0;
	for(n=1;n*(n+1)/2<=x;n++)
	{
		if((x-n*(n+1)/2)%n==0)
		{
		    count++;
		}
	}
	cout<<count;
	return 0;
}

思路:
比如说21:
21=21=1+1*(21-sum(1)/1;
21=10+11=(1+2)+2*(21-sum(2))/2;
21=6+7+8=(1+2+3)+3*(21-sum(3))/3;
21=1+2+3+4+5+6=(1+2+3+4+5+6)+6*(21-sum(6))/6;
所以只要判断x-sum(n)是否除尽n,满足一次,count+1;

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