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:一次ac!两重循环,max10 000 000居然没超时。。跑了266ms

Posted by 0810xk at 2010-01-16 16:20:30 on Problem 2140
In Reply To:一次ac!两重循环,max10 000 000居然没超时。。跑了266ms Posted by:kirsten0302 at 2009-08-07 18:34:38
> #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;
> }
> 
> 想法很普遍啊。。。。。。
第一重循环只需要到K/2即可。。。。。

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