HDU 4569 Special equations (数学题)
来源:互联网 发布:海尔网络电视打开蓝屏 编辑:程序博客网 时间:2024/05/23 12:04
题目地址: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 (数学题)
- 数学题-hdu-4569-Special equations
- HDU 4569 Special equations
- HDU 4569 Special equations 枚举
- Hdu 4569 Special equations 2013长沙邀请赛
- HDU 4569 Special equations 解题报告
- HDU-4569 Special equations (数学)
- hdu 4589 Special equations
- hdu 4569 Special equations ( 必要条件缩小范围后暴力)
- [HDU 4569] Special equations (数学+技巧+脑洞)
- HDU-4569 Special equations (利用数学知识巧妙降低复杂度)
- HDU 1840 Equations【简单数学题】
- Special equations
- HDU 4569 Special equations(思维)——2013 ACM-ICPC长沙赛区全国邀请赛
- hdu4569 Special equations
- hdu4589 Special equations(数论)
- 2013长沙邀请赛Special equations
- Special equations(数学筛)
- 自定义的Notification布局
- 出现一个操作错误 (An operations error occurred)
- jsp 内容过长 显示.....结尾
- dispatch_semaphore_t sema 等待
- sql profile使用说明
- HDU 4569 Special equations (数学题)
- bringSubViewToFrom & bringSubViewToBack 方法
- SQL 清除日志
- android详细解释键盘和鼠标事件[转]
- Oracle 11g 诊断新特性——ADR 简介
- ext direct spring Api
- poj1328 Radar Installation
- mybatis参数映射
- Android编译过程详解(一)