HDU 5478 Can you find it(数学问题)
- 若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) ③
- 根据式子 ② 和 ③ 得:
#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(数学问题)的更多相关文章
- 2015上海网络赛 HDU 5478 Can you find it 数学
HDU 5478 Can you find it 题意略. 思路:先求出n = 1 时候满足条件的(a,b), 最多只有20W对,然后对每一对进行循环节判断即可 #include <iostre ...
- 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 ...
- HDU 4342——History repeat itself——————【数学规律】
History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...
- hdu 1597 find the nth digit (数学)
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU 6659 Acesrc and Good Numbers (数学 思维)
2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...
- HDU 5019 Revenge of GCD(数学)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 Problem Description In mathematics, the greatest ...
- HDU 5476 Explore Track of Point 数学平几
Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...
- hdu 4091 Zombie’s Treasure Chest(数学规律+枚举)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4091 /** 这题的一种思路就是枚举了: 基于这样一个事实:求出lcm = lcm(s1,s2), n ...
- HDU 4099 Revenge of Fibonacci (数学+字典数)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4099 这个题目就是一个坑或. 题意:给你不超过40的一串数字,问你这串数字是Fibonacci多少的开头 ...
随机推荐
- Java中ArrayList问题:删除一个ArrayList中的重复元素,注意留意一个问题
该问题有两种方法: 一 利用两个数组,此法简单,不讨论 二 利用一个数组,从第0个开始依次取元素,并在其后元素中查找是否有该元素,有则删掉后面的重复元素,依次遍历.---但是这种情况要特别注意,当后续 ...
- String的hashCode原理
参考下面这篇文章: http://blog.csdn.net/steveguoshao/article/details/12576849 http://blog.csdn.net/mingli1986 ...
- Linux下的CPU使用率与服务器负载的关系与区别
原文链接:http://blogread.cn/it/article/7444 当我们使用top命令查看系统的资源使用情况时会看到load average,如下图所示,它表示系统在1,5,15分钟的平 ...
- Linux下sqlite的安装与使用
简介 SQLite是一款轻量级数据库,是遵守ACID的关联式数据库管理系统.它的设计目的是嵌入式.目前已经在很多嵌入式产品中使用了它,它占用资源非常的低,在嵌入式设备中,可能只需要几百KB的内存就 ...
- INSERT INTO SELECT FROM 这语句怎么用
如果两表字段相同,则可以直接这样用. insert into table_a select * from table_b 如果两表字段不同,a表需要b中的某几个字段即可,则可以如下使用: insert ...
- style currentStyle getComputedStyle的区别和用法
先介绍下层叠样式表的三种形式: 1.内联样式,在html标签中style属性设置. <p style="color:#f90">内联样式</p> 2.嵌入样 ...
- Codeforces 193D Two Segments 解题报告
先是在蓝桥杯的网站上看到一道题: 给出1~n的一个排列,求出区间内所有数是连续自然数的区间的个数.n<=50000. 由于数据较弱,即使用O(N^2)的算法也能拿到满分. 于是在CF上发现了这一 ...
- cmd 命令行下复制、粘贴的快捷键
1.单击左下角“开始”菜单,选择“运行”,输入“cmd”. 2.在弹出的cmd窗口的标题栏上点击“右键”,选择“属性”. 3.在弹出的对话框中选择“选项”这个选项卡,在“编辑选项”区域中勾选“快速编辑 ...
- DEDECMS使用SQL命令批量替换语句
1.更改文章中的内容 update dede_addonarticle set body=replace(body,'原来的字符','替换后的字符') 2,替换文章标题 update dede_arc ...
- LI 导航
HTML: <div class="my_nav"> <ul> <li class="tiao cur" id="ord ...