poj 1840 Eqs(暴力列挙+hash)
テーマリンク
Eqs
Time Limit:5000 MS
メモリLimit:65536 K
Total Submissions:13405
Acceepted:6583
Description
Consinder equations having the following form:
a 1 x 1
3+a 2 x 2
3+a 3 x 3
3+a 4 x 4
3+a 5 x 5
3=0
The coefficients are given integers from the interval[-50,50]
It is consider a solution a system(x 1,x 2,x 3,x 4,x 5)that verifees the equation,xi(-50,50)xi!0,any i∈{1,2,3,4,5}
Determine how many soutions satisfy the given equation.
Input
The only line of input contains the 5 coefficients a 1,a 2,a 3,a 4,a 5,separated by blanks.
Output
The output will contain on the first line the number of the solutions for the given equation.
Sample Input
コードは以下の通りです
Eqs
Time Limit:5000 MS
メモリLimit:65536 K
Total Submissions:13405
Acceepted:6583
Description
Consinder equations having the following form:
a 1 x 1
3+a 2 x 2
3+a 3 x 3
3+a 4 x 4
3+a 5 x 5
3=0
The coefficients are given integers from the interval[-50,50]
It is consider a solution a system(x 1,x 2,x 3,x 4,x 5)that verifees the equation,xi(-50,50)xi!0,any i∈{1,2,3,4,5}
Determine how many soutions satisfy the given equation.
Input
The only line of input contains the 5 coefficients a 1,a 2,a 3,a 4,a 5,separated by blanks.
Output
The output will contain on the first line the number of the solutions for the given equation.
Sample Input
37 29 41 43 47
Sample Output654
問題を二つに分けて列挙する.先にx 1を列挙して、x 2の値、a 1 x 1^3+a 2 x 2^3のすべての値を統計します(値が大きすぎてここでhashを使います).x 3、x 4、x 5の値を列挙して、答えを統計すればいいです.複雑度O(10^6)コードは以下の通りです
#include
#include
#include
#include
#include
#include
#include