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

一次ac!两重循环,max10 000 000居然没超时。。跑了266ms

Posted by kirsten0302 at 2009-08-07 18:34:38 on Problem 2140
#include<iostream>
using namespace std;

int main ()
{
	int i,j,k;
	int sum,count;
	while (scanf("%d",&k)!=EOF)
	{
		
		count=0;
		for (i=1;i<=k;i++)
		
		{	sum=0;
			for (j=i;j<=k;j++)
			{
				sum=sum+j;
				if (sum>k) break;
				if (sum==k) {count++;continue;} 
			}

		}
		cout<<count<<endl;
	}
	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