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:各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢!

Posted by s2009zy at 2010-03-13 16:22:00 on Problem 1543
In Reply To:各位牛人,有谁有更好的方法你们的怎么是0MS呢? 我的是这样的,希望找到更好的方法!谢谢! Posted by:wuqianhu12 at 2006-12-07 21:15:10
#include<iostream>
using namespace std;
int a[101]={0};

int main()
{
	int n;
	int i,j,k,l;;
	for(i=1;i<=100;i++)
	{
		a[i]=i*i*i;
	}
	scanf("%d",&n);
	for(i=6;i<=n;i++)
	{
		for(j=2;j<=n;j++)
		{
			for(k=j+1;k<=n;k++)
			{
				if((a[j]+a[k])>a[i])
					break;
				for(l=k+1;l<=n;l++)
				{
					if((a[j]+a[k]+a[l])>a[i])
						break;
					if(a[i]==a[j]+a[k]+a[l])
					{
						printf("Cube = %d, Triple = (%d,%d,%d)\n",i,j,k,l);
					}
				}
			}
		}
	}
}



这个是我的代码~~~0MS

不加BREAK;不加k=j+1 l=k+1时候是282MS
加了BREAK后是 63MS
加了k=j+1 l=k+1 后就0MS

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