A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ..., n into each circle separately, and the sum of numbers in two adjacen ...
分类:
其他好文 时间:
2017-07-30 11:41:24
阅读次数:
207
<?phpheader("content-type:text/html;charset=utf-8");//设置编码格式//计算素数,素数是只能被自己和1整除的正整数,特别指出的是我们规定1不是素数/*方法一:定义一个函数计算素数function prime_Number($n){ $c=0;//计 ...
分类:
Web程序 时间:
2017-07-30 11:33:05
阅读次数:
192
题意 ? 给定一个长度为 $n$ 的序列 $A = \left\{ a_1, a_2, ..., a_n \right\}$ . ? 问有多少个三元组 $(i, j, k)(i \ne j, i \ne k, j \ne k)$ , 满足 $\left\{ \begin{aligned} & a_i ...
分类:
其他好文 时间:
2017-07-29 16:27:32
阅读次数:
216
n= int (raw_input())def find_prime(n): L = list(range(2,n + 1)) m = 0 while m < len(L): n = m + 1 while n < len(L): if L[n]%L[m] == 0: del L[n] n = n ...
分类:
其他好文 时间:
2017-07-28 19:30:26
阅读次数:
131
The ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room ...
分类:
其他好文 时间:
2017-07-27 22:34:26
阅读次数:
248
基本定理: 首先看一下核心代码: 核心代码 原理解析: 当初我看不懂这段代码,主要有这么几个问题: 1.定理里面不是一开始写了一个n*xxx么?为什么代码里没有*n? 2.ans不是*(prime[i]-1)么?为什么到了第二个while循环变成*prime[i]了? 3.定理里面不是要/pi么?为 ...
分类:
其他好文 时间:
2017-07-26 22:06:42
阅读次数:
208
题意:给定一个 n 个点和相应的权值,要求你用 n-1 条边连接起来,其中一条边是魔法边,不用任何费用,其他的边是长度,求该魔法边的两端的权值与其他边费用的尽量大。 析:先求出最小生成树,然后再枚举每一条边,求出最大值,任意两点之间的距离可以通过预处理来解决,最小生成树时,要用prime算法,要不然 ...
分类:
编程语言 时间:
2017-07-26 20:26:29
阅读次数:
174
终于能实现HashTable了!!之前看书一直没搞懂compression那的质数是什么意思,看lecture才明白,对prime求余数可以避免keys的hashcode均可被某一数整除从而造成collision过多的情况(这个概念好难形容啊感觉,具体参见lecture哈),compression算 ...
分类:
其他好文 时间:
2017-07-26 19:21:15
阅读次数:
253
Expectation Division Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): ...
分类:
其他好文 时间:
2017-07-25 13:36:00
阅读次数:
147
Prime Distance Description The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the inter ...
分类:
其他好文 时间:
2017-07-25 10:19:12
阅读次数:
196