http://acm.hdu.edu.cn/showproblem.php?pid=1496
题意:求有多少个解!!
Problem Description
Consider equations having the following form:
a*x1^2+b*x2^2+c*x3^2+d*x4^2=0
a, b, c, d are integers from the interval [-50,50] and any of them cannot be 0.
It is consider a solution a system ( x1,x2,x3,x4 ) that verifies the equation, xi
is an integer from[-100,100] and xi != 0, any i ∈{1,2,3,4}.
Determine how many solutions satisfy the given equation.
Input
The input consists of several test cases. Each test case consists of a single line containing the 4 coefficients a, b, c, d, separated by one or more blanks.
End of file.
Output
For each test case, output a single line containing the number of the solutions.
Sample Input
1 2 3 -4
1 1 1 1
Sample Output
39088
0
#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <set>
//#include <map>
#include <queue>
#include <utility>
#include <stack>
#include <list>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <ctype.h>
using namespace std;
int hash[3000005];
int main()
{
int a, b, c, d, x1, x2, x3, x4, res;
while (~scanf ("%d%d%d%d", &a, &b, &c, &d))
{
if (a > 0 && b > 0 && c > 0 && d > 0 || a < 0 && b < 0 && c < 0 && d < 0) //都是同号必定无解,木有这个超时
{
puts ("0");
continue;
}
memset (hash, 0, sizeof(hash));
res = 0;
for (x1 = 1; x1 < 101; x1++) //hash令四重循环变成二重,复杂度大大减少
for (x2 = 1; x2 < 101; x2++)
hash[a*x1*x1+b*x2*x2+2000000]++;
for (x3 = 1; x3 < 101; x3++)
for (x4 = 1; x4 < 101; x4++)
res += hash[(0-(c*x3*x3+d*x4*x4))+2000000];
res *= 16;
//因为正负号不同不影响x平方的效果,所以直接枚举正数,最后乘以2的4次方,表示正负不同的组合
printf ("%d\n", res);
}
return 0;
}
分享到:
相关推荐
HDUACM2010版_14)Hash及应用HDUACM2010版_14)Hash及应用HDUACM2010版_14)Hash及应用HDUACM2010版_14)Hash及应用
官方网站:https://github.com/aappleby/smhasherMurmurHash算法,自称超级快的hash算法,是FNV的4-5倍。官方数据如下: OneAtATime – 354.163715 mb/sec FNV – 443.668038 mb/sec SuperFastHash – 985.335173 ...
内容描述:用于crypto中hash爆破的强大工具。 优势:相较于其他hash工具,具有更快的算力,使用方便简洁。 适用:适用于md5,sha256等典型hash加密方式,反推出所需的源码。
uthash开源的hash函数实现,里面的uthash.h可用
stm32f407平台上实现的hash算法
uthash 是C的比较优秀的开源代码,它实现了常见的hash操作函数,例如查找、插入、删除等待。该套开源代码采用宏的方式实现hash函数的相关功能,支持C语言的任意数据结构最为key值,甚至可以采用多个值作为key,无论...
RS-Hash Function Value: " + ghl.RSHash(key)); System.out.println(" 2. JS-Hash Function Value: " + ghl.JSHash(key)); System.out.println(" 3. PJW-Hash Function Value: " + ghl.PJWHash(key)); System....
5.1.3 Hash函数的迭代构造法 5.2 Hash函数MD5 5.2.1 MD5算法 5.2.2 MD5的安全性 5.3 安全Hash算法SHA-1 5.3.1 SHA-1算法步骤 5.3.2 SHA-1和MD5的比较 5.4 基于分组密码与离散对数的Hash函数 5.4.1 利用分组...
Hash在线解密平台最新版php实现纯txt存储哈希跟明文对应表查询
3维hashin失效准则~复合材料层合板
Hashcat is the self-proclaimed world's fastest password recovery tool. It had a proprietary code base until 2015, but is now released as free software. Versions are available for Linux, OS X, and ...
hashcat is the world’s fastest and most advanced password recovery tool. This version combines the previous CPU-based hashcat (now called hashcat-legacy) and GPU-based oclHashcat. Hashcat is ...
在获取到mysql用户的hash后, 可用hash直接登陆mysql进行操作 比如我们注入出数据库的hash,但是没办法拿到webshell 我们可以使用mysql_hash,用hash登陆并控制数据库 使用方法: mysql_hash.exe -u root -p Enter ...
Hash函数集合,包含主流的hash函数: nginx_hash算法,OpenSSL_hash算法,RSHash,JSHash,PJWHash,ELFHash,BKDRHash,DJBHash,DEKHash,APHash等等!
Hash join算法的一个基本思想就是根据小的row sources(称作build input,我们记较小的表为S,较大的表为B) 建立一个可以存在于hash area内存中的hash table,然后用大的row sources(称作probe input) 来探测前面所建...
217种hashcat-V3.0所支持的哈希 举例,如md4、md5、sha1、sha256,部分特殊哈希的例子有官网说明的链接。
空间索引计算工具类。 1)GeoHash用一个字符串表示经度和纬度两...3)编码的前缀可以标识更大的区域,比如 wx4sv61 编码代表的区域要大于 wx4sv61q 代表的区域,但是 wx4sv61q 代表的区域一定在 wx4sv61 代表的区域内。
基于ABAQUS的hashin和Tong-Norrius准则的umat子程序
abaqus用户子程序,Hashin失效准则,abaqus显示分析,使用三维实体单元