HDU 5478 Can you find it
Can you find it
Time Limit: 8000/5000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 450 Accepted Submission(s): 208
Please output all pairs (a, b) in lexicographical order. (1≤a,b<C). If there is not a pair (a, b), please output -1.
1 22
#include<queue>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
#define N 1234567
#define M 12
int c, k1, b1, k2;
bool flag;
int quickpow(int m,int n,int k)// m^n % k
{
int b = ;
while (n > )
{
if (n & )
b = (b*m)%k;
n = n >> ;
m = (m*m)%k;
}
return b;
}
int main()
{
int tt = ; int b;
while(~scanf("%d %d %d %d", &c, &k1, &b1, &k2))
{ printf("Case #%d:\n", tt++);
flag = ;
for(int a = ; a < c; a++)
{
b = c - quickpow(a,k1+b1,c);
if( ( quickpow(a, k1*+b1, c) + quickpow(b, k2*-k2+, c) ) %c == )
{
printf("%d %d\n",a,b);
flag = ;
}
}
if(flag == )
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 5478 Can you find it(快速幂)
Problem Description Given a prime number C(1≤C≤2×105), and three integers k1, b1, k2 (1≤k1,k2,b1≤109 ...
- HDU 5478 Can you find it(数学问题)
题目大意: 给你 ak1⋅n+b1+ bk2⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...). 要求所有的n都满足上述的式子. 问这样的a,b 有多少对? 分析这个问题 ...
- hdu 5478 (数论)
⋅n+b1⋅n−k2+1 = 0 (mod C)(n = 1, 2, 3, ...) (1<=a, b <C) 1. 当n = 1时, a^(k1+b1) + b = 0 ( mod ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
随机推荐
- joyoi1935 「Poetize3」导弹防御塔
#include <iostream> #include <cstring> #include <cstdio> #include <queue> #i ...
- luogu3629 [APIO2010]巡逻
创造一个环出来,可以让环上的边都只访问一次. 对于 \(k=1\),答案就是树的直径两边连起来. 倘若 \(k=2\),那就先按照 \(k=1\) 的求一遍,然后我们发现,如果第二条加的边构成的环和第 ...
- suse-12-linux gcc gcc-c++离线安装教程,不使用yum等
最近这几天接手新的项目,要部署新的服务器,采用目前比较主流的框架开发的程序,前后端进行了分离.在这种情况下就需要使用nginx做代理,以便于很好的区分前后端,目前虽然已经有很多很好的发布体系,但是个人 ...
- Jmeter接口测试-简单分析结果数、聚合报告以及图形结果(二)
简单分析结果数.聚合报告以及图形结果 结果树 取样器结果:返回值报200,表示执行接口调试成功 请求:发送的数据 响应数据:返回的数据 Thread Name:线程组名称 Sample Start: ...
- 【JavaScript 6—基础知识点】:正则表达式(应用)
导读:其实,我不像大家一样,从一开始就重视着正则表达式,我甚至都觉得好浪费时间浪费精力,都没用的.因为,如果我要判断是不是为数字,我可以使用Numberic()方法,如果要去空格的话,使用trim() ...
- HDU——2955Robberies(小数背包)
Robberies Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- bzoj1853: [Scoi2010]幸运数字 dp+容斥原理
在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的“幸运号码”是十进制表示中只包含数字6和8的那些号码,比如68,666,888都是“幸运号码”!但是这种“幸运号码”总是 ...
- Yii 之视图布局
控制器代码: //设置的布局文件 public $layout = 'common'; public function actionAbout(){ $data = array('page_name' ...
- Linux 下 GCC 编译共享库控制导出函数的方法
通过一些实际项目的开发,发现这样一个现象,在 Windows 下可以通过指定 __declspec(dllexport) 定义来控制 DLL(动态链接库)中哪些函数可以导出,暴露给其他程序链接使用,哪 ...
- [delphi]修改indy源码后重新编译
http://blog.csdn.net/nerdy/article/details/8702568 虽然indy有一身的毛病,但是一般情况下使用起来还是多方便的. 今天在做一个使用到indy的程序的 ...