HDU ACM 1496 Equations
Equations
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3978 Accepted Submission(s): 1602
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.
End of file.
#include<stdio.h>
#include<string.h>
#define MAXN 50001
int num[MAXN], store[MAXN]; int hash(int cur)
{
int temp = cur%MAXN;
if(temp < ) temp += MAXN;
while(num[temp] != && store[temp] != cur)
{
temp = (temp+)%MAXN;
}
return temp;
} int main()
{
// freopen("input.txt", "r", stdin);
int rate[], a, b, c, d, i, j, sum, temp, res;
for(i=; i<; ++i) rate[i] = i*i;
while(scanf("%d%d%d%d", &a, &b, &c, &d) != EOF)
{
if((a>&&b>&&c>&&d>) || (a<&&b<&&c<&&d<))
{
printf("0\n");
continue;
}
memset(num, , sizeof(num));
for(i=; i<; ++i)
for(j=; j<; ++j)
{
temp = a*rate[i]+b*rate[j];
res = hash(temp);
store[res] = temp;
num[res]++;
} sum = ; for(i=; i<; ++i)
for(j=; j<; ++j)
{
temp = -(c*rate[i]+d*rate[j]);
res = hash(temp);
sum += num[res];
} printf("%d\n", sum****);
}
return ;
}
HDU ACM 1496 Equations的更多相关文章
- hdu 1496 Equations
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 Equations Description Consider equations having ...
- hdu 1496 Equations hash表
hdu 1496 Equations hash表 题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=1496 思路: hash表,将原来\(n^{4}\)降 ...
- hdu acm 1028 数字拆分Ignatius and the Princess III
Ignatius and the Princess III Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...
- HDU 1496 Equations(哈希表)
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=1496 [题目大意] 给出一个方程ax1^2+bx2^2+cx3^2+dx4^2=0,求-100到1 ...
- HDU 1496 Equations hash HDU上排名第一!
看题传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1496 题目大意: 给定a,b,c,d.a*x1^2+b*x2^2+c*x3^2+d*x4^2=0 ...
- HDU 1496 Equations 等式(二分+暴力,技巧)
题意:给出4个数字a,b,c,d,求出满足算式a*x1^2+b*x2^2+c*x3^2+d*x4^2=0的 (x1,x2,x3,x4) 的组合数.x的范围[-100,100],四个数字的范围 [-50 ...
- HDU - 1496 Equations (hash)
题意: 多组测试数据. 每组数据有一个方程 a*x1^2 + b*x2^2 + c*x3^2 + d*x4^2 = 0,方程中四个未知数 x1, x2, x3, x4 ∈ [-100, 100], 且 ...
- HDU ACM 题目分类
模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- Spring中的mappingResources和mappingDirectoryLocations
今天使用Spring+Hibernate进行事务管理,按照顺序也就是配置,DataSource,Sessionfactory,事务管理器以及拦截器. DateSource可以直接使用Hibernate ...
- UVa 10075 - Airlines
航线算球面距离,需要经纬度转空间坐标. 任意两点间距离用Floyd求出来,查询时直接查表. #include <cstdio> #include <map> #include ...
- Classpath entry org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER will not be exported
打开navigator,修改下面的classpath文件: 将<classpathentry kind="con" path="org.maven.ide.ecli ...
- 车牌识别LPR(四)-- 车牌定位
第四篇:车牌定位 车牌定位就是采用一系列图像处理或者数学的方法从一幅图像中将车牌准确地定位出来.车牌定位提取出的车牌是整个车牌识别系统的数据来源,它的效果的好坏直接影响到整个系统的表现,只有准确地定位 ...
- Android开发之android:process=":remote"
由于每个应用程序都运行在自己的进程空间,并且可以从应用程序UI运行另一个服务进程,而且经常会在不同的进程间传递对象.在Android平台,一个进程通常不能访问另一个进程的内存空间,所以要想对话,需要将 ...
- 关于fft的一点总结
好吧,其实我并没有深入运用fft,只会优化卷积 听说fft经常和生成函数结合在一起………………oi真是迅猛发展,我真是与时代脱节了…… 关于fft的学习推荐直接去看算法导论,写得非常清楚 主要弄懂n次 ...
- bzoj1053: [HAOI2007]反素数ant
51nod有一道类似的题...我至今仍然不会写暴搜!!! #include<cstdio> #include<cstring> #include<iostream> ...
- 全球最受欢迎的十大Linux发行版(图)
帮助新的Linux用户在越来越多的Linux发行版中选择最合适的操作系统,是创建这个网页的原因.它列出了迄今为止最流行的10个Linux发行版(另外增加的是FreeBSD,到目前为止最为流行的BSD系 ...
- P2P直播、点播技术学习经验
自8月份以来一直埋头学习P2P在音/视频直播.点播上的学习,受到不少网友的帮助,在此也留下自己学到的一点点的经验. 第一个接触的开源项目是peercast,应该说上手非常快,这必须感谢王浩聪的注释版, ...
- ORACLE CLIENT客户端安装步骤详解
下载地址: http://download.oracle.com/otn/nt/oracle11g/112010/win32_11gR2_client.zip 先将下载下来的ZIP文件解压,并运行se ...