![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数论
Below_Crusder
这个作者很懒,什么都没留下…
展开
-
欧几里得模板以及扩展欧几里得
#include #include "stdio.h"#include "stdlib.h"#include "string.h"#include "math.h"using namespace std;#define N 50005 int gcd(int a,int b){ if(b==0) return a; else return原创 2015-09-17 20:01:26 · 385 阅读 · 0 评论 -
快速幂模板
int B_pow(int a,int b) //快速幂 { int ans=1; while(b) { if(b&1) ans*=a; a*=a; b>>=1; } return ans; }POJ 3070(矩阵快速幂)#include #include "原创 2015-09-17 20:03:56 · 296 阅读 · 0 评论 -
POJ1142 暴力质因数分解+素数测试
#include #include "stdio.h"#include "stdlib.h"#include "string.h"#include "math.h"using namespace std;#define N 50005typedef long long int ll;int primelist[1000]={0};int isprime(in原创 2015-09-17 20:08:54 · 508 阅读 · 0 评论 -
ZOJ 3870(数学)
//题意:从一堆数字中任选两个数字,使其异或后的值大于这两个数字的任意一个 求这样的数字有多少对//方法: 如果要两个数字异或后的值大于任意一个 // 只需要大的那个元素的最高位大于小的那个元素的最高位且// 小的元素的最高位对应的大的元素的该位上的数字为0即可// 利用数组bits[i](二进制最高位为i的数字有多原创 2016-03-26 14:31:38 · 380 阅读 · 0 评论 -
HDU 5666
//题解BC上有 Round #80 1002#include #include #include #include #include using namespace std;long long multi(long long a, long long b, long long p) //快速乘法 因为long long会爆{ long long sum = 0;原创 2016-04-17 22:26:54 · 410 阅读 · 0 评论 -
BZOJ 2818(莫比乌斯反演)
最近刚看莫比乌斯反演 数学不好是硬伤啊 不过总算跑出来了第一种是没优化的跑这题#include #include using namespace std;const int maxn = 1e7 + 5;int isprime[maxn];int prime[maxn];int mu[maxn];int cnt;void mobi(int n){ memset(原创 2016-05-02 19:43:20 · 601 阅读 · 0 评论 -
SPOJ PGCD - Primes in GCD Table (莫比乌斯)
//题意:给定两个数和,其中,,求为质数的有多少对?其中和的范 围是。//方法:莫比乌斯反演#include #include #include using namespace std;const int maxn = 1e7 + 5;int isprime[maxn];int p[maxn];int u[maxn];int g[maxn];int s原创 2016-05-02 20:13:03 · 436 阅读 · 0 评论