2015上海网络赛 HDU 5478 Can you find it 数学
题意略。
思路:先求出n = 1 时候满足条件的(a,b), 最多只有20W对,然后对每一对进行循环节判断即可
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#define LL long long
#define eps 1e-8
#define INF 0x3f3f3f3f
#define MAXN 200005
using namespace std;
LL C, k1, b1, k2;
LL quick_mod(LL x, LL y, LL mod){
if (y == ) return ;
LL res = quick_mod(x, y >> , mod);
res = res * res % mod;
if (y & ){
res = res * x % mod;
}
return res;
}
LL a[MAXN][];
LL b[MAXN];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // OPEN_FILE
int cas = ;
while (~scanf("%I64d%I64d%I64d%I64d", &C,&k1, &b1, &k2)){
printf("Case #%d:\n", cas++);
int t = ;
for (int i = ; i < C; i++){
LL m = quick_mod((LL)i, k1 + b1, C);
if (m == ) continue;
a[++t][] = i;
a[t][] = C - m;
b[t] = m;
}
bool noans = true;
for (LL i = ; i <= t; i++){
LL pa = b[i];
LL pa_k1 = quick_mod(a[i][], k1, C);
LL pb_k2 = quick_mod(a[i][], k2, C);
LL pb = a[i][];
LL xx = pa;
LL yy = pb;
// pb_k2 = quick_mod(pb_k2, 10000, C);
LL x = pa_k1, y = pb_k2;
bool flag = false;
for (int j = ; j <= ; j++){
pa = pa * x % C;
pb = pb * y % C;
if (pa == xx && pb == yy){
break;
}
if ((pa + pb) % C != ){
flag = true;
break;
}
}
if (flag) continue;
printf("%I64d %I64d\n", a[i][], a[i][]);
noans = false;
}
if (noans){
printf("-1\n");
}
}
}
2015上海网络赛 HDU 5478 Can you find it 数学的更多相关文章
- 2015上海网络赛 HDU 5475 An easy problem 线段树
题意就不说了 思路:线段树,维护区间乘积.2操作就将要除的点更新为1. #include<iostream> #include<cstdio> #include<cstr ...
- hdu 5476 Explore Track of Point(2015上海网络赛)
题目链接:hdu 5476 今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3.4个小时,我想到一半时发现样例输出是 ...
- 2015合肥网络赛 HDU 5489 Removed Interval LIS+线段树(树状数组)
HDU 5489 Removed Interval 题意: 求序列中切掉连续的L长度后的最长上升序列 思路: 从前到后求一遍LIS,从后往前求一遍LDS,然后枚举切开的位置i,用线段树维护区间最大值, ...
- 2015合肥网络赛 HDU 5492 Find a path 动归
HDU 5492 Find a path 题意:给你一个矩阵求一个路径使得 最小. 思路: 方法一:数据特别小,直接枚举权值和(n + m - 1) * aver,更新答案. 方法二:用f[i][j] ...
- 2015上海网络赛 A Puzzled Elena
题意:给定一棵树,求这个节点的所有子树中包括他本身与它互质的节点的个数. 解题思路:题利用dfs序+容斥原理+前缀和性质解决.题目中要求每个结点,和多少个它的子结点互素.如果每次为了求一个点去跑一遍d ...
- 2014上海网络赛 HDU 5053 the Sum of Cube
水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> ...
- ccpc 网络赛 hdu 6155
# ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...
- 2015北京网络赛 D-The Celebration of Rabbits 动归+FWT
2015北京网络赛 D-The Celebration of Rabbits 题意: 给定四个正整数n, m, L, R (1≤n,m,L,R≤1000). 设a为一个长度为2n+1的序列. 设f(x ...
- 2015北京网络赛 J Scores bitset+分块
2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...
随机推荐
- cogs 181. [USACO Jan07] 最高的牛
181. [USACO Jan07] 最高的牛 ★★ 输入文件:tallest.in 输出文件:tallest.out 简单对比时间限制:1 s 内存限制:32 MB FJ's N ( ...
- Extjs4.2 tooltip 提示宽度问题解决
在Extjs4.2 的tooltip 提示,宽度被限制在了40px,感觉非常别扭,是个BUG,解决的方法,在ext-all-debug.js或ext-all.js中,找到例如以下的代码: Ext.de ...
- hadoop-03-安装java
hadoop-03-安装java 1,su root 2, rpm -qa|grep jdk #查看已经安装的jdk 3,rpm -e --nodeps `rpm -qa|grep jdk ` #删除 ...
- POJ3370&HDU1808 Halloween treats【鸽巢原理】
题目链接: id=3370">http://poj.org/problem?id=3370 http://acm.hdu.edu.cn/showproblem.php?pid=1808 ...
- STL源代码学习(vector篇)
#include <concept_checks.h> #include<stl_allocate.h> /// The vector base class's constru ...
- JDK的安装及配置环境变量
开发java程序的必备工具:JDK,全名是Java Development Kit, 是Java语言的软件开发工具包. 第一步:下载安装包 从Oracle官网可以选择自己所需的版本下载,(附Oracl ...
- 双系统给ubuntu增加分区
http://www.th7.cn/system/lin/201506/106338.shtml http://www.linuxidc.com/Linux/2012-06/61983.htm 因为本 ...
- poj_3371
一道模拟题,写的有点麻烦 #include<iostream> #include<cstring> #include<cstdio> #include<alg ...
- hdoj--2516--取石子游戏(博弈)
取石子游戏 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Subm ...
- nfs共享文件服务搭建
网络文件共享服务器192.10.19.132yum install -y nfs-utils 在exports文件中添加的从机范围vim /etc/exports/home/nfs/ 192.10.1 ...