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 数学的更多相关文章

  1. 2015上海网络赛 HDU 5475 An easy problem 线段树

    题意就不说了 思路:线段树,维护区间乘积.2操作就将要除的点更新为1. #include<iostream> #include<cstdio> #include<cstr ...

  2. hdu 5476 Explore Track of Point(2015上海网络赛)

    题目链接:hdu 5476 今天和队友们搞出3道水题后就一直卡在这儿了,唉,真惨啊……看着被一名一名地挤出晋级名次,确实很不好受,这道恶心的几何题被我们3个搞了3.4个小时,我想到一半时发现样例输出是 ...

  3. 2015合肥网络赛 HDU 5489 Removed Interval LIS+线段树(树状数组)

    HDU 5489 Removed Interval 题意: 求序列中切掉连续的L长度后的最长上升序列 思路: 从前到后求一遍LIS,从后往前求一遍LDS,然后枚举切开的位置i,用线段树维护区间最大值, ...

  4. 2015合肥网络赛 HDU 5492 Find a path 动归

    HDU 5492 Find a path 题意:给你一个矩阵求一个路径使得 最小. 思路: 方法一:数据特别小,直接枚举权值和(n + m - 1) * aver,更新答案. 方法二:用f[i][j] ...

  5. 2015上海网络赛 A Puzzled Elena

    题意:给定一棵树,求这个节点的所有子树中包括他本身与它互质的节点的个数. 解题思路:题利用dfs序+容斥原理+前缀和性质解决.题目中要求每个结点,和多少个它的子结点互素.如果每次为了求一个点去跑一遍d ...

  6. 2014上海网络赛 HDU 5053 the Sum of Cube

    水 #include <stdio.h> #include <stdlib.h> #include<math.h> #include<iostream> ...

  7. ccpc 网络赛 hdu 6155

    # ccpc 网络赛 hdu 6155(矩阵乘法 + 线段树) 题意: 给出 01 串,要么询问某个区间内不同的 01 子序列数量,要么把区间翻转. 叉姐的题解: 先考虑怎么算 \(s_1, s_2, ...

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

  9. 2015北京网络赛 J Scores bitset+分块

    2015北京网络赛 J Scores 题意:50000组5维数据,50000个询问,问有多少组每一维都不大于询问的数据 思路:赛时没有思路,后来看解题报告也因为智商太低看了半天看不懂.bitset之前 ...

随机推荐

  1. 【codeforces 46C】Hamsters and Tigers

    [题目链接]:http://codeforces.com/problemset/problem/46/C [题意] 给你一个长度为n的01串; 让你把所有的0放在一起,把所有的1放在一起; (即0都是 ...

  2. cogs 181. [USACO Jan07] 最高的牛

    181. [USACO Jan07] 最高的牛 ★★   输入文件:tallest.in   输出文件:tallest.out   简单对比时间限制:1 s   内存限制:32 MB FJ's N ( ...

  3. EularProject 42:单词解码出来的三角形数

    Coded triangle numbers Problem 42 The nth term of the sequence of triangle numbers is given by, tn = ...

  4. 12、NIO、AIO、BIO一

    1.NIO概述 什么是NIO:NIO是New I/O的简称,与旧式的基于流的I/O方式相对,从名字看,他表示新的一套JAVA I/O标准.它是在java1.4中被纳入到JDK中的,并具有以下特性: - ...

  5. mysql-创建和操作表

    一.建表 为了用程序创建表,我们可以使用SQL的create table 语句.如下: 每个列之间用逗号隔开,每列的定义以列名开始,后跟列的数据类型. 表的主键可以在创建表时用primary key关 ...

  6. PAT(B) 101-111-1-2014-03-01

    1.个位数统计: #include<stdio.h> #include<iostream> #include<string.h> #include<set&g ...

  7. sicily 1000. LinkedList

    Description template <typename E> class LinkedList { private:     // inner class: linked-list ...

  8. IIS 7.5 配置

    安装 MVC 3 对应版本. 或者对应的版本. 登陆时候报错 检查下面几项是否配置正确 检查ASP.net 是否开启. 检查网站的应用池是否配置正确 在处理程序映射当中检查这几项是否配置正确 如果都配 ...

  9. sql的系统关键字的概述

    create proc proc_B as SELECT * FROM [ZkbTest].[dbo].[T_ZKB] exec sp_helptext proc_B select * from sy ...

  10. vue2.0 兄弟组件数据传递方法

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...