HDU 4569 Special equations(枚举+数论)(2013 ACM-ICPC长沙赛区全国邀请赛)
Then comes T lines, each line starts with an integer deg (1<=deg<=4), meaning that f(x)'s degree is deg. Then follows deg integers, representing an to a0 (0 < abs(an) <= 100; abs(ai) <= 10000 when deg >= 3, otherwise abs(ai) <= 100000000, i<n). The last integer is prime pri (pri<=10000).
Remember, your task is to solve f(x) 0 (mod pri*pri)
#include <cstdio>
#include <iostream>
#include <cstring>
#include <queue>
using namespace std;
typedef long long LL; const int MAXN = ; int T, deg;
LL phi;
LL a[MAXN]; LL f(LL x, LL m) {
LL ret = , xx = ;
for(int i = ; i <= deg; ++i) {
ret = (ret + a[i] * xx) % m;
xx = (xx * x) % m;
}
return ret;
} LL ans, ret;
int t; void solve() {
for(ans = ; ans < phi; ++ans) {
if(f(ans, phi) == ) {
for(ret = ans; ret <= phi * phi; ret += phi)
if(f(ret, phi * phi) == ) {
printf("Case #%d: %d\n", t, (int)ret);
return ;
}
}
}
printf("Case #%d: No solution!\n", t);
} int main() {
cin>>T;
for(t = ; t <= T; ++t) {
cin>>deg;
for(int i = deg; i >= ; --i) cin>>a[i];
cin>>phi;
solve();
}
}
HDU 4569 Special equations(枚举+数论)(2013 ACM-ICPC长沙赛区全国邀请赛)的更多相关文章
- 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(数学推论)
题目 //想不出来,看了解题报告 /* 题意:给你一个最高幂为4的一元多项式,让你求出一个x使其结果模p*p为0. 题解:f(x)%(p*p)=0那么一定有f(x)%p=0,f(x)%p=0那么一定有 ...
- HDU 4741 Save Labman No.004 2013 ACM/ICPC 杭州网络赛
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4741 题意:给你两条异面直线,然你求着两条直线的最短距离,并求出这条中垂线与两直线的交点. 需要注意的是 ...
- 2013 ACM-ICPC长沙赛区全国邀请赛—Special equations
……但是没仔细看,直接跳过了 这题直接枚举就可以过了 ;}
- HDU 4571 Travel in time ★(2013 ACM/ICPC长沙邀请赛)
[题意]给定N个点,每个点有一个停留所需的时间Ci,和停留能够获得的满意度Si,有M条边,每条边代表着两个点走动所需的时间ti,现在问在规定的T时间内从指定的一点S到E能够获得的最大的满意度是多少?要 ...
- HDU 4573 Throw the Stones(动态三维凸包)(2013 ACM-ICPC长沙赛区全国邀请赛)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4573 Problem Description Remember our childhood? A fe ...
- 2013 ACM/ICPC 长沙现场赛 C题 - Collision (ZOJ 3728)
Collision Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge There's a round medal ...
- HDU 4571 Travel in time(最短路径+DP)(2013 ACM-ICPC长沙赛区全国邀请赛)
Problem Description Bob gets tired of playing games, leaves Alice, and travels to Changsha alone. Yu ...
随机推荐
- 使用fir.im和蒲公英进行测试的一些注意事项
前言:使用fir.im和蒲公英进行测试的一些注意事项 最近公司的项目遇到了一个问题,有的用户的手机系统版本低于9.3高于9.0的存在崩溃的情况,8.x的系统的用户的有的界面的显示有问题(比如说图片严重 ...
- 使用补丁破解IntelliJ IDEA 2017收费版本(转)
1. 首先去官网http://www.jetbrains.com/idea/download/#section=windows下载Ultimate版(注意不是community版)下载并安装.一定要记 ...
- Javascript和android原生互调
最近在做原生和js端的互调的功能,自己改了个demo,给大家讲解下. 先上js代码 <!DOCTYPE html> <html> <head> <meta c ...
- nginx 方向代理
#nginx 监听原理 先监听端口 --> 再配置域名 -->匹配到就访问local 否则 没有匹配到域名就默认访问第一个监听端口的local地址 # vi nginx.conf user ...
- win7 bat copy 一个文件 到另外的文件夹内,路径得用引号哦
win 7 的 用引号 把路径引起来 ,但是win10 的可以不用哦 !
- jquery mobile 移动web(3)
可折叠功能块. div 元素的 data-role 属性设置为 collapsible 代码如下: <div data-role="collapsible"> < ...
- Spring的声明式事务----Annotation注解方式(2)
使用步骤: 步骤一.在spring配置文件中引入<tx:>命名空间<beans xmlns="http://www.springframework.org/schema/b ...
- JS数组去重的十种方法(转载)
重点:博客原文出自http://www.cnblogs.com/yuanbo88/p/7345331.html.我只是想给自己做个笔记.感谢敲代码的怪蜀黍做的贡献. Methods 1: 思路:定义一 ...
- [USACO1.5]数字三角形 Number Triangles
题目描述 观察下面的数字金字塔. 写一个程序来查找从最高点到底部任意处结束的路径,使路径经过数字的和最大.每一步可以走到左下方的点也可以到达右下方的点. 7 3 8 8 1 0 2 7 4 4 4 5 ...
- C语言学习记录_2019.01.29
C语言的灵魂:指针 #include <stdio.h> int main(int argc, char **argv) { printf("Hello, World!\n&q ...