摘要:
定义:Mp=2p-1,当p为素数,且Mp为素数,则称Mp为梅森素数 当p为第几个素数,则称Mp为第几个梅森数 判定: Lucas-Lehmer判定法:判定一个梅森数是否是梅森素数 设p是素数,第p个梅森数为Mp为2p-1,r1 = 4,对于k >= 2 r(k) = r(k-1)^2-2(modM( 阅读全文
摘要:
利用Linux有关系统调用函数编写一个文件工具filetools,要求具有下列功能: 1 #include<stdio.h> 2 #include<sys/types.h> 3 #include<unistd.h> 4 #include<fcntl.h> 5 #include<sys/stat.h> 阅读全文
摘要:
定义:给定正整数n,小于等于n的正整数之中,有多少个数与n互质 计算个数的公式 欧拉函数,φ(n)表示 欧拉函数证明: 1. n = 1, φ(1) = 1 。1与任何数(包括自身)互质 2. n为质数, φ(n)=n-1 。质数n与小于n的数互质(除了自身) 3. 如果n是质数的次方 n = p^ 阅读全文
摘要:
欧几里得算法(辗转相除) gcd(a,b),用于计算a,b的最大公约数 gcd(a, b) = g(b, a%b) 证明(反证法): 设 r=a%b , c=gcd(a,b) 则 a=xc , b=yc , 其中x , y互质 r=a%b=a-pb=xc-pyc=(x-py)c 因为gcd(a,b) 阅读全文
摘要:
解决的问题:今有物不知其数,三三数之剩二,五五数之剩三,七七数之剩二。问物几何? 求最小符合的数 阅读全文
摘要:
队列的相关函数 头文件#include<bitset> queue<int> que; 对于一个叫做que的队列: q.push(x); 入队,将x接到队列的末端。 q.pop(); 出队,弹出队列的第一个元素,注意,并不会返回被弹出元素的值。 q.front(),访问队首元素,即最早被压入队列的元 阅读全文
摘要:
#include<cstdio>#include<cstdlib>#include<cstring>#include<iostream>#include<algorithm>using namespace std; const int maxn=3000005;long long oula[maxn 阅读全文
摘要:
//矩阵快速幂,本题二阶矩阵#include<cstdio>#include<cstring>#include<cstdlib>#include<iostream>#include<algorithm>using namespace std; const int mod = 1e9+7;struct 阅读全文
摘要:
#include<stdio.h>int main(){ int n,d; while(~scanf("%d %d",&n,&d))//输入总人数和去除数 { long long w=0; for(int i=2;i<=n;i++) w=(w+d)%i; printf("%d %d %I64d\n" 阅读全文
摘要:
#include<cstdio>inline void in(int &x){ char c=getchar(); int f=1; x=0; while (c<'0'||c>'9') { if (c=='-') f=-f; c=getchar(); } while (c>='0'&&c<='9') 阅读全文