题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4569

题意:给你一个最高幂为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!

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <iterator>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <cctype>
using namespace std; typedef __int64 LL;
const int N=1;
const LL mod=1000000007LL;
const int INF=0x3f3f3f3f;
const double PI=acos(-1.0); LL xi[6],p2,p;
int n; LL ff(LL x,LL k)
{
LL sum=0,ans=1;
for(int i=0;i<=n;i++)
{
sum=(sum+xi[i]*ans)%k;
ans*=x;
}
return (sum+k)%k;
} void xiaohao()
{
LL i,x,x2;
for(x=0;x<p;x++)
{
LL t=ff(x,p);
if(t%p==0)
{
for(x2=x;x2<p2;x2+=p)
{
LL t2=ff(x2,p2);
if(t2%p2==0)
{
printf("%I64d\n",x2);
return ;
}
}
}
}
printf("No solution!\n");
} int main()
{
int i,j,T,ca=0;
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(i=n;i>=0;i--)
scanf("%I64d",&xi[i]);
scanf("%I64d",&p);
p2=p*p;
printf("Case #%d: ",++ca);
xiaohao();
}
return 0;
}

HDU 4569 Special equations (数学题)的更多相关文章

  1. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  2. 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 ...

  3. HDU 4569 Special equations(数学推论)

    题目 //想不出来,看了解题报告 /* 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有 ...

  4. HDU4569 Special equations

    /* HDU4569 Special equations http://acm.hdu.edu.cn/showproblem.php?pid=4569 数论 题意:f(x)为一n次方程求是否存在x, ...

  5. HDU 5839 Special Tetrahedron

    HDU 5839 Special Tetrahedron 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n ...

  6. HDU 5839 Special Tetrahedron (计算几何)

    Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  7. HDU 5839 Special Tetrahedron 计算几何

    Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  8. HDU 3395 Special Fish(拆点+最大费用最大流)

    Special Fish Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Tot ...

  9. HDU 5839 Special Tetrahedron (2016CCPC网络赛08) (暴力+剪枝)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5839 在一个三维坐标,给你n个点,问你有多少个四面体(4个点,6条边) 且满足至少四边相等 其余两边不 ...

随机推荐

  1. 官网下载旧版本的Xcode

    1.登录“苹果开发者中心”——>“SDKs” 2.点击“Xcode” 3.点击页面顶部的“Download” 4.点击页面左下方的“additional tools”,这样就可以查询到各个Xco ...

  2. <jsp:directive.page>标签

    directive 英 [dɪ'rektɪv; daɪ-] 美 [daɪ'rɛktɪv] n. 指示:指令 adj. 指导的:管理的 等效于 <%page import="com.ct ...

  3. java——String的那边破事

    经典的先看下面一段代码,请问最终创建几个对象,分别在哪里? String s0 = new String("luoliang.me"); String s1 = "luo ...

  4. 对discuz的代码分析学习(三)mysql驱动

    一. 属性分析         1.tablepre :表名称前缀        2.version : 数据库版本        3.drivertype:驱动类型        4.querynu ...

  5. lombk在IDEA中报ClassNotFoundException错误

    今天接手了一个项目,用到了lombk,第一次用到,做为纯JAVA来说,确实不错. 不过在使用中碰到了一个问题,就是在IDEA中,可以在结构中看到getter和setter等都已经正确的生成了,但是运行 ...

  6. 认识和理解css布局中的BFC

    认识和理解css布局中的BFC BFC的定义 是 W3C CSS 2.1 规范中的一个概念,它决定了元素如何对其内容进行定位,以及与其他元素的关系和相互作用. Block Formatting Con ...

  7. android 背景透明度渐变动画

    button.setVisibility(View.VISIBLE); // 背景透明度渐变动画 ObjectAnimator alpha = ObjectAnimator.ofFloat(butto ...

  8. 记WebUtility.HtmlDecode将&nbsp;转成特殊空格的问题

    在.net中 System.Web.HttpUtility.HtmlDecode(或者WebUtility.HtmlDecode) 方法会将   解码为特殊空格(Ascii值为,对应的值为:\u00A ...

  9. Eclipse怎么全局搜索替换(整个项目)

    链接地址:http://jingyan.baidu.com/article/3ea51489c1c0d752e61bba2e.html 我们用Eclipse编程,有时候需要将整个项目的某个字符串替换成 ...

  10. C#通过WebBrowser快速扒站思路积累大量着陆页列表

    现在工作方向已经越来越倾向于项目产品运营相关的东西.对线上运营也有了一定程度的了解. 配合一些技术性的操作,能极大的便利工作中的各种高难度任务,快速提升自我,积累丰富的经验和资源. 以近期制作LP为例 ...