题意:

多组测试数据。

每组数据有一个方程 a*x1^2 + b*x2^2 + c*x3^2 + d*x4^2 = 0,方程中四个未知数 x1, x2, x3, x4 ∈ [-100, 100], 且都不为0。

给定a, b, c, d ∈ [-50, 50] ,且都不为0, 求上述条件下方程解的个数。

比赛的时候想到的是枚举三个,另一个可以直接算出来。但是一直TLE。。。结果就没做出来。

看了题解,用的hash,很巧妙。结果自己用map写还是T。。最后用数组写的。     _φ(❐_❐✧

#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
#define maxn 1000000 int hsh[*maxn+];
int main()
{
int a, b, c, d;
while(~scanf("%d%d%d%d", &a, &b, &c, &d))
{
int ans = ;
memset(hsh, , sizeof(hsh)); for (int x1 = ; x1 <= ; x1++)
for (int x2 = ; x2 <= ; x2++)
hsh[maxn + x1*x1*a + x2*x2*b]++; for (int x3 = ; x3 <= ; x3++)
for (int x4 = ; x4 <= ; x4++)
ans += hsh[maxn - (x3*x3*c + x4*x4*d)]; printf("%d\n", ans*);
}
}

HDU - 1496 Equations (hash)的更多相关文章

  1. HDU 1496 Equations(哈希表)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=1496 [题目大意] 给出一个方程ax1^2+bx2^2+cx3^2+dx4^2=0,求-100到1 ...

  2. HDU 1840 Equations (数学)

    title: Equations 数学 杭电1840 tags: [数学] 题目链接 Problem Description All the problems in this contest tota ...

  3. HDU 4821 String (HASH)

    题意:给你一串字符串s,再给你两个数字m l,问你s中可以分出多少个长度为m*l的子串,并且子串分成m个长度为l的串每个都不完全相同 首先使用BKDRHash方法把每个长度为l的子串预处理成一个数字, ...

  4. HDU 2523 sort (hash)

    #include<iostream> #include<cstring> #include<cmath> #include<cstdio> using ...

  5. hdu 1496 Equations hash表

    hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...

  6. HDU 5934 Bomb(炸弹)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  7. 哈希(Hash)与加密(Encrypt)相关内容

    1.哈希(Hash)与加密(Encrypt)的区别 哈希(Hash)是将目标文本转换成具有相同长度的.不可逆的杂凑字符串(或叫做消息摘要),而加密(Encrypt)是将目标文本转换成具有不同长度的.可 ...

  8. HDU 5734 Acperience(返虚入浑)

    p.MsoNormal { margin: 0pt; margin-bottom: .0001pt; text-align: justify; font-family: Calibri; font-s ...

  9. HDU 5724 Chess(国际象棋)

    HDU 5724 Chess(国际象棋) Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Oth ...

随机推荐

  1. css文本换行的问题

    今天敲代码的时候发现了一个一直都没太注意的小问题,当我在一个200px的div中写了一长串的‘f ‘时发现没有换行 但加上空格或标点符号后就能自动换行 原来浏览器把它当成了一串完整的单词,所以默认不换 ...

  2. 069 Sqrt(x) 求平方根

    实现 int sqrt(int x) 函数.计算并返回 x 的平方根.x 保证是一个非负整数.案例 1:输入: 4输出: 2案例 2:输入: 8输出: 2说明: 8 的平方根是 2.82842..., ...

  3. 转Keil 中使用 STM32F4xx 硬件浮点单元

    Keil 中使用 STM32F4xx 硬件浮点单元一.前言有工程师反应说 Keil 下无法使用 STM32F4xx 硬件浮点单元, 导致当运算浮点时运算时间过长,还有 一些人反应不知如何使用芯片芯片内 ...

  4. js获取ISO8601规范时间

    var d = new Date(); d.setHours(d.getHours(), d.getMinutes() - d.getTimezoneOffset()); console.log(d. ...

  5. c#ADSL拨号类

    class ADSLHelper { /// <summary> ///拨号 /// </summary> /// <param name="connectio ...

  6. 192.168.28.168:3000打开网页无法调试localhost为前缀的接口

    最近我在IIS上发布.net Core API的时候发现 当我用localhost去打开我的web项目时 并且,ajax调用的接口前缀为localhost时候,运行正确 但是当我用192.168.28 ...

  7. angularjs实现导航菜单切换高亮

    <ul> <li ng-repeat="(index, item) in headerList"> <a ui-sref="{{item.h ...

  8. 【虚拟机-网络IP】保留正在使用的 VIP

    本文包含以下内容 适用场景 操作步骤 保留IP的费用 适用场景 我们希望云服务有一个固定的 IP,即使虚拟机以 deallocated 的方式关闭. 用户忘记先保留 VIP 而直接完成了部署. 希望不 ...

  9. 利用jieba第三方库对文件进行关键字提取

    已经爬取到的斗破苍穹文本以TXT形式存储 代码 import jieba.analyse path = 'C:/Users/Administrator/Desktop/bishe/doupo.text ...

  10. code Gym 100500D T-shirts(暴力)

    因为只能买一次,暴力枚举一下买的衣服的大小. #include<cstdio> #include<map> #include<algorithm> using na ...