从1到s选出k个数 他们的最大公约数大于1 求方案数
容斥 S(1)-S(2)+S(3) S(x)为选出k个数的公因子个数为x的数量
#include
#include
#include
using namespace std;
typedef long long LL;
const int maxn = 55;
int prime[maxn], vis[maxn];
int n, m;...
分类:
其他好文 时间:
2014-11-07 11:21:15
阅读次数:
146
C++ Primer第五版这本书是久负盛名的C++经典教程,本篇博文为C++Primer(第五版)中文版第九章课后编程习题解答。...
分类:
编程语言 时间:
2014-11-07 09:57:06
阅读次数:
267
有人问我这个问题。
个人感觉暴搜会TLE O(n*sqrt(n))。n=100000000;(判断素数用2~sqrt(n)+1 去除)
还是枚举好了。枚举 1~10000,把他每一位存下来,回文数已知 left ,求 right ,然后组合起来。
例如 1 ,判断 11 是否素数。
例如 10 ,判断 101 是否素数, 判断 1001 是否素数。
这样复杂度就是 O(n^2)。 开始我 bool pa[100000000] 准备用标记来确定。结果MLE。
然后算了一下 总共有多少个数,最多 781 个。 ...
分类:
其他好文 时间:
2014-11-06 22:03:02
阅读次数:
172
package myscala15import myscala.Element.elemimport myscala.Elementsealed abstract class Expr case class Var(name: String) extends Exprcase class Numbe...
分类:
其他好文 时间:
2014-11-06 19:06:34
阅读次数:
274
H -
Happy 2006
Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d
& %I64u
Submit
Status
Description
Two positive integers are said to be relatively prime to each o...
分类:
移动开发 时间:
2014-11-06 09:26:50
阅读次数:
157
Prime Test
Time Limit: 6000MS
Memory Limit: 65536K
Total Submissions: 24514
Accepted: 5730
Case Time Limit: 4000MS
Description
Given a big integer number, you are ...
分类:
其他好文 时间:
2014-11-05 23:13:24
阅读次数:
237
Power of CryptographyBackgroundCurrent work in cryptography involves (among other things) large prime numbers and computing powers of numbers modulo f...
分类:
其他好文 时间:
2014-11-05 21:03:37
阅读次数:
237
n全排列输出:int WPermutation(int num, bool bRepeat)num表示num全排列bRepeat标志是否产生反复元素的序列。int Permutation(int n, int* A, int cur, bool bRepeat) { static int numbe...
分类:
其他好文 时间:
2014-11-05 14:35:28
阅读次数:
114
Description
The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians for thousands of years is the qu...
分类:
其他好文 时间:
2014-11-05 00:33:10
阅读次数:
200
C++ Primer第五版这本书是久负盛名的C++经典教程,本篇博文为C++Primer(第五版)中文版第八章课后编程习题解答。...
分类:
编程语言 时间:
2014-11-04 19:45:55
阅读次数:
301