题目

//想不出来,看了解题报告

/*
题意:给你一个最高幂为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(数学推论)的更多相关文章

  1. HDU 4569 Special equations(取模)

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

  2. HDU 4569 Special equations (数学题)

    题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=4569 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p ...

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

  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 5584 LCM Walk 数学

    LCM Walk Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5584 ...

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

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

  8. HDU 5839 Special Tetrahedron 计算几何

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

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

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

随机推荐

  1. LD_PRELOAD

    下面的helloworld会在屏幕上打印出什么内容? 1 2 3 4 5 6 #include <stdio.h> int main(int argc, char* argv[], cha ...

  2. MYSQL 一些用法

    LOAD DATA LOCAL INFILE 'C:/xampp/htdocs/test/file/sample.csv' INTO TABLE sample1 FIELDS TERMINATED B ...

  3. 48.Warning: (vsim-3534) [FOFIR] - Failed to open file "sp_rom_8x256_sr.mif" for reading.

    当在仿真ROM IP核文件时,会出现这种警告,而这种警告的结果是ROM不能输出数据,原因是mif文件要放在modelsim工程文件目录下.类似的,有时候会报错,Failed to open file& ...

  4. Abstract Class与 Interface 的区别

    表格                                                                                               Abs ...

  5. 四则运算2+psp0级表格

    四则运算2 一.题目和要求 题目:写一个能自动生成小学四则运算题目的程序,要求一次输出不少于30道,只能是整数100以内的四则运算(四则运算1升级版) 要求: 1.题目避免重复 2.可定制(数量/打印 ...

  6. 随机四则运算 C语言

    设计思想:出三十道一百以内数的随机四则运算题目,先随机两个一百以内的数字,再通过随机数确定四则运算算符,最后通过for循环输出三十道 源代码程序: #include <stdlib.h># ...

  7. Ztree的初步使用--checkbox--指定目录下搜索子节点

    这里记录一下zTree的check的使用 首先 <%@ Page Language="C#" AutoEventWireup="true" CodeBeh ...

  8. apache与tomcat负载集群的3种方法

    花了两天时间学习apache与tomcat的集成方法,现在把学习成果记录下来. apache与tomcat负载集群集成方法有3种jk.jk_proxy.http_proxy 本次集成使用的软件版本: ...

  9. 三级联动(ajax)

    <body> <div id="zhuti"></div> </body><script type="text/ja ...

  10. 线段树--Color the ball(多次染色问题)

    K - Color the ball Time Limit:3000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u ...