Eqs

题目:Eqs

方法一:纯暴力

#include<iostream>
using namespace std;
int a1, a2, a3, a4, a5;
int cnt;
int main()
{
	cin>>a1>>a2>>a3>>a4>>a5;
	for(int x1=-50; x1<=50; x1++){
		if(x1==0)continue;
		for(int x2=-50; x2<=50; x2++){
			if(x2==0)continue;
			for(int x3=-50; x3<=50; x3++){
				if(x3==0)continue;
				for(int x4=-50; x4<=50; x4++){
					if(x4==0)continue;
					for(int x5=-50; x5<=50; x5++){
						if(x5==0)continue;
						if(a1*x1*x1*x1+a2*x2*x2*x2+a3*x3*x3*x3+a4*x4*x4*x4+a5*x5*x5*x5==0)
							cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
 } 

方法二:哈希

题解

posted @ 2023-02-14 08:37  TFLSNOI  阅读(33)  评论(0)    收藏  举报