现在的位置: 首页 > 综合 > 正文

poj 1840 (数学)

2014年01月18日 ⁄ 综合 ⁄ 共 675字 ⁄ 字号 评论关闭

点击打开链接

政府对称,注意0的情况。。。

#include<stdio.h>
#include<string.h>
short mark1[25000001];
int main()
{
	int a[105];
	int b[5];
	int i,j;
	j=0;
	
	int temp;
	for(i=-50;i<=50;i++)
	{
		if(i==0)continue;
		a[j]=i*i*i;
		j++;
		
	}
	while(scanf("%d%d%d%d%d",&b[0],&b[1],&b[2],&b[3],&b[4])!=EOF)
	{
		    memset(mark1,0,sizeof(mark1));
		//	memset(mark2,0,sizeof(mark2));
		int q,w,e,r,t,i,j;
		for(i=0;i<100;i++)
		{
			for(j=0;j<100;j++)
			{
				if(!a[j])continue;
			    temp=a[i]*b[3]+a[j]*b[4];
				if(temp<0)
					temp+=25000000;
			        mark1[temp]++;
				//else mark2[temp]++;
			}
		}
		__int64 ans=0;
		int temp;
		for(q=0;q<100;q++)
		{
			for(w=0;w<100;w++)
				for(e=0;e<100;e++)
					{
						temp=b[0]*a[q]+b[1]*a[w]+b[2]*a[e];
						if(temp<0)
						{
							temp+=25000000;
							//ans+=mark2[temp];
						}
						//else 
							ans+=mark1[temp];
					}
		}
		printf("%I64d\n",ans);
	}
	return 0;
}

抱歉!评论已关闭.