题意:给定 C,k1, b1, k2 找出所有的(a, b)满足 ak1⋅n+b1+ bk2⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...)  (1<=a, b <C)

1.  当n = 1时, a^(k1+b1) + b = 0 ( mod C)   => a^(2 * k1+b1) + b*a^(k1) = 0 ( mod C)     ①

当n = 2时, a^(2 * k1 + b1) + b^(k2 + 1) = 0 (mod C)       ②

所以  ① ,②结合  可以推出 b^(k2) = a^(k1)

所以求出 a ,b再判断是否符合本式即可

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll; ll pow_mod(int a,int n,int mod)
{
if(n == 0)
return 1;
ll x = pow_mod(a,n/2,mod);
ll ans = (ll)x*x%mod;
if(n %2 == 1)
ans = ans *a % mod;
return ans;
} int main()
{
int b1,k1,k2,mod;
int cas = 1;
while(scanf("%d%d%d%d",&mod,&k1,&b1,&k2) != EOF)
{
bool flag = false;
printf("Case #%d:\n",cas++);
for(int i = 1; i < mod; i++)
{
ll tmp = pow_mod(i,k1+b1,mod);
int b = mod - tmp;
ll tta = pow_mod(i,k1,mod);
ll ttb = pow_mod(b,k2,mod);
if(tta == ttb)
{
flag = true;
printf("%d %d\n",i,b);
}
}
if(!flag)
printf("-1\n");
}
return 0;
} 2. 求出1 - c所有的a ,b 的情况,再枚举n进行判断,但感觉不是很靠谱- - #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
typedef long long ll; ll pow_mod(ll a,ll n,ll mod)
{
if(n == 0)
return 1;
ll x = pow_mod(a,n/2,mod);
ll ans = (ll)x*x%mod;
if(n %2 == 1)
ans = ans *a % mod;
return ans;
} int main()
{
ll b1,k1,k2;
ll mod;
int cas = 1;
while(scanf("%I64d%I64d%I64d%I64d",&mod,&k1,&b1,&k2) != EOF)
{
bool flag = true;
int ok;
printf("Case #%d:\n",cas++);
for(ll i = 1; i < mod; i++)
{
ll temp = pow_mod(i,k1+b1,mod);
ll b = (temp/mod + 1)*mod - temp;
ok = 1;
for(ll j = 2; j <= 100; j++)
{
ll ans1 = pow_mod(i, k1 * j + b1, mod);
ll ans2 = pow_mod(b, k2 * j - k2 + 1, mod);
ll ans = (ans1+ans2)%mod;
if(ans)
{
ok = 0;
break;
}
}
if(ok)
{
flag = 0;
printf("%I64d %I64d\n",i,b);
}
}
if(flag)
printf("-1\n");
}
return 0;
}

  

hdu 5478 (数论)的更多相关文章

  1. 2015上海网络赛 HDU 5478 Can you find it 数学

    HDU 5478 Can you find it 题意略. 思路:先求出n = 1 时候满足条件的(a,b), 最多只有20W对,然后对每一对进行循环节判断即可 #include <iostre ...

  2. GCD and LCM HDU 4497 数论

    GCD and LCM HDU 4497 数论 题意 给你三个数x,y,z的最大公约数G和最小公倍数L,问你三个数字一共有几种可能.注意123和321算两种情况. 解题思路 L代表LCM,G代表GCD ...

  3. HDU 5478 Can you find it 随机化 数学

    Can you find it Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pi ...

  4. HDU 4497 数论+组合数学

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4497 解题思路:将满足条件的一组x,z,y都除以G,得到x‘,y',z',满足条件gcd(x',y' ...

  5. hdu 4542 数论 + 约数个数相关 腾讯编程马拉松复赛

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=4542 小明系列故事--未知剩余系 Time Limit: 500/200 MS (Java/Others) ...

  6. hdu 4961 数论?

    http://acm.hdu.edu.cn/showproblem.php?pid=4961 给定ai数组; 构造bi, k=max(j | 0<j<i,a j%ai=0), bi=ak; ...

  7. hdu 1664(数论+同余搜索+记录路径)

    Different Digits Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

  8. hdu 3641 数论 二分求符合条件的最小值数学杂题

    http://acm.hdu.edu.cn/showproblem.php?pid=3641 学到: 1.二分求符合条件的最小值 /*================================= ...

  9. hdu 4059 数论+高次方求和+容斥原理

    http://acm.hdu.edu.cn/showproblem.php? pid=4059 现场赛中通过率挺高的一道题 可是容斥原理不怎么会.. 參考了http://blog.csdn.net/a ...

随机推荐

  1. vmware ubuntu蓝屏

    ctrl+alt+f4 sudo apt-get update sudo apt-get upgrade sudo apt-get install xserver-xorg-lts-utopic su ...

  2. Spring事务注意点

    service中未带事务的方法调用了自身带事务的方法时,按下面写法数据是提交不了的. public String getMaxSystemVersionNo() { SystemVersion ver ...

  3. bzoj千题计划275:bzoj4817: [Sdoi2017]树点涂色

    http://www.lydsy.com/JudgeOnline/problem.php?id=4817 lct+线段树+dfs序 操作1:access 操作2:u到根的-v到根的-lca到根的*2+ ...

  4. markdown最基本的几种语法

    1.标题 # 相当于<h1></h1> ## 相当于<h2></h2> ### 相当于<h3></h3> #### 相当于< ...

  5. 微信小程序如何动态增删class类名

    简述 由于微信小程序开发不同于以往的普通web开发, 因此无法通过js获取wxml文件的dom结构, 因此从js上直接添加一个类名应该不可能了. 可是我们可以通过微信小程序数据绑定以及view标签的& ...

  6. Python内置函数(7)——sum

    英文文档: sum(iterable[, start]) Sums start and the items of an iterable from left to right and returns ...

  7. 电梯模拟C++

    1.问题描述与要求 模拟某校九层教学楼的电梯系统.该楼有一个自动电梯,能在每层停留,其中第一层是大楼的进出层,即是电梯的"本垒层",电梯"空闲"时,将来到该层候 ...

  8. 写一个vue组件

    写一个vue组件 我下面写的是以.vue结尾的单文件组件的写法,是基于webpack构建的项目.如果还不知道怎么用webpack构建一个vue的工程的,可以移步到vue-cli. 一个完整的vue组件 ...

  9. Server.MapPath找不到命名空间,解决办法

    最近在做微信公众号开发,在网上找了个例子实现获取Access_token的值,需要读取xml文件,结果就遇到这个问题

  10. R语言学习 第九篇:plyr包

    在数据分析中,整理数据的本质可以归纳为:对数据进行分割(Split),然后应用(Apply)某些处理函数,最后将结果重新组合(Combine)成所需的格式返回,简单描述为:Split - Apply ...