HDU 4569 Special equations(数学推论)
//想不出来,看了解题报告 /*
题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有f(x+p)%p=0。 所以我们可以开始从0到p枚举x,当f(x)%p=0,然后再从x到p*p枚举,不过每次都是+p,找到了输出即可,没有的话No solution!
*/ #include<stdio.h>
int main()
{
int t,n;
__int64 a[],p;
scanf("%d",&t);
for(int id=;id<=t;id++)
{
scanf("%d",&n);
for(int i=n;i>=;i--)
{
scanf("%I64d",&a[i]);
}
scanf("%I64d",&p);
printf("Case #%d: ",id);
__int64 ee=p*p;
int flag=;
for(__int64 x=;x<=p;x++)
{
__int64 ss=;
__int64 xx=;
for(int i=;i<=n;i++)
{
ss+=(a[i]*xx);
xx*=x;
}
if(ss%p==)
{
for(__int64 y=x;y<=ee;y+=p)
{
__int64 sss=;
__int64 xxx=;
for(int ii=;ii<=n;ii++)
{
sss+=(a[ii]*xxx);
xxx*=y;
}
if(sss%ee==)
{
flag=;
printf("%I64d\n",y);
break;
}
}
}
if(flag==)break;
}
if(flag==)
printf("No solution!\n");
}
return ;
}
HDU 4569 Special equations(数学推论)的更多相关文章
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4569 Special equations (数学题)
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4569 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p ...
- HDU 4569 Special equations(枚举+数论)(2013 ACM-ICPC长沙赛区全国邀请赛)
Problem Description Let f(x) = anxn +...+ a1x +a0, in which ai (0 <= i <= n) are all known int ...
- HDU4569 Special equations
/* HDU4569 Special equations http://acm.hdu.edu.cn/showproblem.php?pid=4569 数论 题意:f(x)为一n次方程求是否存在x, ...
- HDU 5839 Special Tetrahedron
HDU 5839 Special Tetrahedron 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n ...
- HDU 5584 LCM Walk 数学
LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...
- HDU 5839 Special Tetrahedron (计算几何)
Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- HDU 5839 Special Tetrahedron 计算几何
Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...
- HDU 3395 Special Fish(拆点+最大费用最大流)
Special Fish Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
随机推荐
- 迭代器、泛型和增强For
Iterator hasNext next Iterator 迭代器 Collection提供了一个遍历集合的通用方式,迭代器(Iterator). 获取迭代器的方式是使用Collection定义的 ...
- UITableView表视图以及重建机制
表视图UITableView 表视图UITableView,是IOS中最重要的视图,随处可见 表视图通常用来管理一组具有相同数据结构的数据 UITableView继承自UIScrollView,所 ...
- Quartus II Error总结与解答
(1).Error (209015): Can't configure device. Expected JTAG ID code 0x020B20DD for device 1, but found ...
- 学习jax-ws(一)
1.生成文件时提示class not find ,需要加个cp .,这样就行了 E:\mylearn\learn_webservice\learnJax-ws\bin>wsgen -cp . w ...
- How to check if NSString begins with a certain character
How to check if NSString begins with a certain character How do you check if an NSString begins with ...
- 【收藏】Myeclipse优化
1 .关闭MyEclipse的自动validation windows > perferences > myeclipse > validation 将Bui ...
- CS小分队第一阶段冲刺站立会议(5月9日)
昨日完成工作:对新子项目进行构思规划 遇到问题:不知道如何将excel表导入C#,对于timer控件不熟悉 今日计划:完成将存在EXCEL表中的名单导入,并进行抽号,熟悉timer控件
- C++编程显示四则运算题目
题目:C++编程显示四则运算题目 设计思路:(1)让用户自己确定出题的数量,同时显示加减乘除四则运算. (2)考虑到用户可能只会一种运算,因此可以选择运算.
- source insight 完全卸载和重装
Source insight的卸载不干净,会影响之后的安装 切入正题,完美卸载source insight的方法: 一.在pc的控制面板—>程序—>卸载程序 找到source insigh ...
- WPF入门学习
WPF基础知识 总结的学习WPF的几点基础知识: 1) C#基础语法知识(或者其他.NET支持的语言):这个是当然的了,虽然WPF是XAML配置的,但是总还是要写代码的,相信各位读者应该也都有这个基础 ...