随笔分类 - 数论篇
发表于 2018-04-13 21:18阅读:173评论:0推荐:0
摘要:题目链接 题意:问从A到B中与N互素的个数。 题解: 利用容斥原理:先求出与n互为素数的个数。 可以先将 n 进行素因子分解,然后用区间 x 除以 素因子,就得到了与 n 的 约数是那个素因子的个数,然后每次这样求一遍,但是发现有重 复的:举个例子 [1,10] 区间中与 6 互素的个数,应该是 1
阅读全文 »
发表于 2018-04-11 18:58阅读:174评论:0推荐:0
摘要:题目链接 Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 25841 Accepted: 6382 Description Consider two natural numbers A and B. Let S be
阅读全文 »
发表于 2018-03-28 11:23阅读:402评论:0推荐:0
摘要:Square Number: Description In mathematics, a square number is an integer that is the square of an integer. In other words, it is the product of some i
阅读全文 »
发表于 2018-03-17 15:14阅读:145评论:0推荐:0
摘要:Description In mathematics, a square number is an integer that is the square of an integer. In other words, it is the product of some integer with its
阅读全文 »
发表于 2018-03-16 21:48阅读:134评论:0推荐:0
摘要:#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> #include <vector> #include <ma
阅读全文 »
发表于 2018-03-15 22:16阅读:348评论:0推荐:0
摘要:1、什么是逆元 当求解公式:(a/b)%m 时,因b可能会过大,会出现爆精度的情况,所以需变除法为乘法: 设c是b的逆元,则有b*c≡1(mod m); 则(a/b)%m = (a/b)*1%m = (a/b)*b*c%m = a*c(mod m); 即a/b的模等于a*b的逆元的模; 2、求逆元的
阅读全文 »
发表于 2018-03-08 23:46阅读:104评论:0推荐:0
摘要:ll quickmod(ll a,ll n) { ll ans=1; while(n) { if(n&1) ans=(ans*a)%mod; a=(a*a)%mod; n>>=1; } return ans; }
阅读全文 »