题目大意:

给你  ak1⋅n+b1+ bk2⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...). 要求所有的n都满足上述的式子。
问这样的a,b 有多少对?
 
分析这个问题的时候需要补充一下余数的性质定理。
 
  • 若a≡b (% p),则对于任意的c,都有(a + c) ≡ (b + c) (%p);
  • 若a≡b (% p),则对于任意的c,都有(a * c) ≡ (b * c) (%p);
  • 若a≡b (% p),c≡d (% p),
    则 (a + c) ≡ (b + d) (%p),
         (a - c) ≡ (b - d) (%p),
         (a * c) ≡ (b * d) (%p),
         (a / c) ≡ (b / d) (%p);
     
    ===============================================================================
    n = 1  ........................   a^(k1+b1) + b  = 0(Mod C)  ①
    n = 2 .........................   a^(2*k1+b1) + b^(k2+1) = 0 (Mod C)  ②

    设 ①*a^k1 .................................. a(2*k1+b1) + a^k1*b = 0(Mod C)  ③

  • 根据式子  ② 和 ③ 得:
          a^(2*k1+b1) + b^(k2+1) <=> a(2*k1+b1) + a^k1*b
          化简后:  b^k2 <=> a^k1
所以经过上面式子的证明,可以得知,我们只要前两项Mod C == 0 那么 这个a和b就是符合的。
 
 
=======================================================================================================
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const LL INF = 0xffffff;
const LL maxn = ;
const LL MOD = 1e9+;
LL C, k1, k2, b1; LL QuickPow(LL a, LL k, LL mod)
{
LL ans = , P = a;
while( k )
{
if(k% == )
ans = (ans * P)%mod;
k /= ;
P = (P * P)%mod;
}
return ans;
} int main()
{
LL ans = , a, b;
int cas = ; while(cin >> C >> k1 >> b1 >> k2)
{
ans = ;
printf("Case #%d:\n", cas ++); for(int i=; i<C; i++)///枚举a
{
a = i;
b = C - QuickPow(a, k1+b1, C);
if( (QuickPow(a, *k1+b1, C) + QuickPow(b, k2+, C))%C == )
{
printf("%I64d %I64d\n", a, b);
ans ++;
} }
if(ans == )
printf("-1\n");
}
return ;
}
 
 
 

HDU 5478 Can you find it(数学问题)的更多相关文章

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

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

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

  3. HDU 4342——History repeat itself——————【数学规律】

    History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...

  4. hdu 1597 find the nth digit (数学)

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. HDU 6659 Acesrc and Good Numbers (数学 思维)

    2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...

  6. HDU 5019 Revenge of GCD(数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 Problem Description In mathematics, the greatest ...

  7. HDU 5476 Explore Track of Point 数学平几

    Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  8. hdu 4091 Zombie’s Treasure Chest(数学规律+枚举)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4091 /** 这题的一种思路就是枚举了: 基于这样一个事实:求出lcm = lcm(s1,s2), n ...

  9. HDU 4099 Revenge of Fibonacci (数学+字典数)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4099 这个题目就是一个坑或. 题意:给你不超过40的一串数字,问你这串数字是Fibonacci多少的开头 ...

随机推荐

  1. Map的迭代操作

    Map的迭代操作 public static void main(String[] args) { Map<String, List<Integer>> map = new H ...

  2. 升级 node 版本

    npm install -g n n stablen v0.10.26 n 0.10.26

  3. Mac下载并编译Google安卓AOSP项目代码

    Mac下载并编译Google安卓AOSP项目代码 参考 https://source.android.com/source/index.html 这两天用Mac下载安卓AOSP源码,且把遇到的问题记下 ...

  4. vpn的作用

    1.可以用于远程对方桌面. 步骤: 1.浏览器中访问网址,输入用户名,密码即可 2.输入远程桌面用户名和网址

  5. 关于ASIHTTPRequest连续请求,并发连续,间隔时间很小崩溃问题

    在不停的刷新ASIHttpRequest的网络请求时,总是在刷新几次之后,整个app崩溃掉.我的app使用的ARC模式,以为可以自动释放到request的请求.经过摸索,还是需要在dealloc函数加 ...

  6. CDH5 集群安装教程

    一.虚拟机的安装和网络配置. 1.虚拟机安装. 2.安装CentOS-6.5 64位版本. 桥接模式: Master: 内存:3G: 硬盘容量40G: 4核: Slave: 内存2G: 硬盘容量30G ...

  7. Codeforces 441D Valera and Swaps(置换群)

    题意: 给定一个1~n的排列(n<=3000),输出字典序最小且次数最少的交换操作,使得操作后的排列可以通过最少m次交换得到排列[1,2,...n] Solution: 可以将排列的对应关系看做 ...

  8. Linux(Debian)下Maven的安装

    Maven的下载地址:http://maven.apache.org/download.cgi这里以最新的3.3.9版本为例进行安装,在这之前需要确保机器上已经安装了JDK. -- 在home文件夹中 ...

  9. Mvvm绑定datagrid或listview的selectItems的方法[转]

    单选,很简单,将SelectedItem与ViewModel的属性进行双向绑定就OK了 多选,由于ListView的SelectedItems不能进行绑定,需要将ListView的SelectionC ...

  10. DOM对象控制HTML无素——详解2

    节点属性 在文档对象模型 (DOM) 中,每个节点都是一个对象.DOM 节点有三个重要的属性 : 1. nodeName : 节点的名称 2. nodeValue :节点的值 3. nodeType ...