摘要: 欧拉函数:即求1到正整数n之间与n互质的数的个数。(特别的, 当 n = 1 时, 数目F(n) = 1) 。 现在分析一下, 当n大于1时的情况, 当 n 为素数时, 很显然 F(n) = n-1 。当n不是素数时,有唯一分解定理可知, n 可以分解成 几个 素数 乘积的形式。例如4 = 2 *... 阅读全文
posted @ 2015-05-20 23:01 草滩小恪 阅读(209) 评论(0) 推荐(0)
摘要: 无需多言直接上代码吧! 1 //Eratosthenes 筛法(埃拉托斯特尼筛法) 2 memset(check, false, sizeof(check)) 3 int tot = 0; 4 for(int i=2; iN) break;21 check[i*prime[j]] ... 阅读全文
posted @ 2015-05-20 21:17 草滩小恪 阅读(207) 评论(0) 推荐(0)
摘要: 样例输入:4 23 410 12 28 12816 12345样例输出:127512325536358 1 //纯粹模拟算法 2 #include 3 #include 4 using namespace std; 5 6 const int maxn = 20; 7 int s[1n) bre... 阅读全文
posted @ 2015-05-20 13:33 草滩小恪 阅读(435) 评论(0) 推荐(0)
摘要: 每辆火车都从A方向驶入车站,再从B方向驶出车站,同时它的车厢可以进行某种形式的重新组合。假设从A方向驶来的火车有n节车厢(n 2 #include 3 using namespace std; 4 5 const int maxn = 1000 + 10; 6 int n, target[maxn... 阅读全文
posted @ 2015-05-20 13:15 草滩小恪 阅读(591) 评论(0) 推荐(0)