快速幂+素数表
chen_zan_yu_
同是寒窗苦读,岂能甘拜下风
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Carmichael Numbers (卡迈克尔数+素数打表+快速幂)
Carmichael Numbers An important topic nowadays in computer science is cryptography. Some people even think that cryptography is the only important field in computer science, and that life would no...原创 2018-11-04 23:02:56 · 2357 阅读 · 0 评论 -
n内素数的个数和n内的素数
#include<bits/stdc++.h>using namespace std;const int maxn =650005;int prime[maxn];//第 i个素数bool is_prime[maxn+1];//is_prime[i]为true表示素数int sieve(int n){ int p=0; for(int i=0; i&l...原创 2018-11-04 23:26:42 · 591 阅读 · 0 评论 -
判决素数个数
输入两个整数X和Y,输出两者之间的素数个数(包括X和Y)。Input两个整数X和Y(1 <= X,Y <= 10 5)。Output输出一个整数,表示X,Y之间的素数个数(包括X和Y)。Sample Input1 100Sample Output25#include<bits/stdc++.h>using namespace st...原创 2018-11-05 00:09:22 · 649 阅读 · 0 评论 -
快速幂模板
typedef long long ll;ll mod_pow(ll x,ll n,ll mod){ ll res=1; while(n>0) { if(n&1) res=res*x%mod; x=x*x%mod; n>>=1; } return res;...原创 2018-11-05 00:15:57 · 218 阅读 · 0 评论 -
P1226 【模板】快速幂||取余运算
题目描述输入b,p,k的值,求b^p mod k的值。其中b,p,k*k为长整型数。输入输出格式输入格式: 三个整数b,p,k. 输出格式: 输出“b^p mod k=s”s为运算结果 输入输出样例输入样例#1: 复制2 10 9输出样例#1: 复制2^10 mod 9=7#include<bits/stdc++.h...原创 2018-11-05 00:52:05 · 269 阅读 · 0 评论 -
越狱
滴答滴答---题目链接 监狱有连续编号为1...N的N个房间,每个房间关押一个犯人,有M种宗教,每个犯人可能信仰其中一种。如果 相邻房间的犯人的宗教相同,就可能发生越狱,求有多少种状态可能发生越狱 Input 输入两个整数M,N.1<=M<=10^8,1<=N<=10^12 Output 可能越狱的状态数,模100003取余 Sample Inp...原创 2018-11-17 17:48:10 · 498 阅读 · 0 评论 -
快速幂取模算法
所谓的快速幂,实际上是快速幂取模的缩写,简单的说,就是快速的求一个幂式的模(余)。在程序设计过程中,经常要去求一些大数对于某个数的余数,为了得到更快、计算范围更大的算法,产生了快速幂取模算法。我们先从简单的例子入手: 求(a^b)%c=?算法1.直接设计这个算法:int ans = 1;for(int i = 1;i<=b;i++){ ans = ans * a;}...原创 2019-05-24 20:49:42 · 3082 阅读 · 0 评论
分享