HDU 5478 Can you find it(快速幂)
Problem Description
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<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<stdlib.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<iostream>
#define exp 1e-10 using namespace std; __int64 Quick_Mod(int a, int b, int m)
{
__int64 res = ,term = a % m;
while(b)
{
if(b & ) res = (res * term) % m;
term = (term * term) % m;
b >>= ;
}
return res%m;
} int main()
{
int c,k1,b1,k2,t;
int f;
t=;
while(cin>>c>>k1>>b1>>k2)
{
cout<<"Case #"<<t++<<":"<<endl;
f=;
int a,b,x,y;
for(a=;a<c;++a)
{
x=Quick_Mod(a,k1,c);
b=c-Quick_Mod(a,k1+b1,c);
y=Quick_Mod(b,k2,c);
if(x==y)
{
f=;
cout<<a<<" "<<b<<endl;
}
}
if(f==)
{
cout<<-<<endl;
} } return ;
}
HDU 5478 Can you find it(快速幂)的更多相关文章
- hdu 5667 BestCoder Round #80 矩阵快速幂
Sequence Accepts: 59 Submissions: 650 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536 ...
- hdu 4686 Arc of Dream(矩阵快速幂)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=4686 题意: 其中a0 = A0ai = ai-1*AX+AYb0 = B0bi = bi-1*BX+BY ...
- HDU 4686 Arc of Dream 矩阵快速幂,线性同余 难度:1
http://acm.hdu.edu.cn/showproblem.php?pid=4686 当看到n为小于64位整数的数字时,就应该有个感觉,acm范畴内这应该是道矩阵快速幂 Ai,Bi的递推式题目 ...
- HDU 2157 How many ways?? (邻接矩阵快速幂)
http://acm.hdu.edu.cn/showproblem.php?pid=2157 题意 : 给定一个有向图,问从A点恰好走k步(允许重复经过边)到达B点的方案数mod p的值 从这道题 ...
- HDU - 4990 Reading comprehension 【矩阵快速幂】
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=4990 题意 初始的ans = 0 给出 n, m for i in 1 -> n 如果 i 为奇 ...
- HDU 1005 Number Sequence:矩阵快速幂
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1005 题意: 数列{f(n)}: f(1) = 1, f(2) = 1, f(n) = ( A*f(n ...
- HDU 2604 Queuing( 递推关系 + 矩阵快速幂 )
链接:传送门 题意:一个队列是由字母 f 和 m 组成的,队列长度为 L,那么这个队列的排列数为 2^L 现在定义一个E-queue,即队列排列中是不含有 fmf or fff ,然后问长度为L的E- ...
- HDU 5793 A Boring Question (逆元+快速幂+费马小定理) ---2016杭电多校联合第六场
A Boring Question Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- hdu 1575 Tr A(矩阵快速幂)
今天做的第二道矩阵快速幂题,因为是初次接触,各种奇葩错误整整调试了一下午.废话不说,入正题.该题应该属于矩阵快速幂的裸题了吧,知道快速幂原理(二进制迭代法,非递归版)后,剩下的只是处理矩阵乘法的功夫了 ...
随机推荐
- 深入理解DLL文件
1.LIB与DLL文件的区别 DLL是一个完整的程序,称为“动态链接库”,DLL中包含的主要有三块内容:1.全部变量 2.函数接口 3.资源:DLL中有一个函数导出表,其中每一项都是一个函数名称.通过 ...
- Codeforces Educational Codeforces Round 3 A. USB Flash Drives 水题
A. USB Flash Drives 题目连接: http://www.codeforces.com/contest/609/problem/A Description Sean is trying ...
- opencv官网
http://wiki.opencv.org.cn/index.php/Template:Doc
- 关于对defer的理解.
代码 <script defer> function init(){ document.getElementById("div").innerHTML="OK ...
- [MEAN Stack] First API -- 3. Select by ID with Mongoose and Express
Mongoose allows you to easily select resources by ID from your MongoDB. This is an important aspect ...
- Eclipse中R文件不能自动生成
R文件不能自动生成主要是因为编译有错误,这时你想什么办法都是没有用的,clean, fix properties,都不是从根上解决问题. R文件主要是自动生成资源文件的id的,里边静态子类 ...
- ext2磁盘布局
概述 本篇博客主要关注ext2文件系统的磁盘布局,即ext2会在格式化时将磁盘划分成什么样子. ext2磁盘布局 任何Ext2分区中的第一个块从不受Ext2文件系统的管理, ...
- Java_基础_内存管理
把没几多年,完全忘记了把自己学的东西记录下来了,现在也基本不知道怎么去记录会更好了,不过好歹妹是把住了~也要毕业了,继续回来写东东记录自己的学习...... 一个Java程序在运行时的内存分布主要如上 ...
- 548 - Tree (UVa OJ)
Tree You are to determine the value of the leaf node in a given binary tree that is the terminal nod ...
- 关于测试Windows电脑端口的命令 —— telnet用法
telnet服务在win7默认是打开的,如果没有打开要在电脑中打开. 命令格式:telnet ip port 例如:telnet 127.0.0.1 80 或者 telnet www.XXX.com ...