Problem Description
Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 +...
分类:
其他好文 时间:
2015-04-22 11:36:55
阅读次数:
137
第一个是判断素数,先上代码吧: 1 from math import sqrt 2 def is_prime(i): 3 if i == 2: 4 return True 5 elif i list[e+1]: list[e],list[e+1...
分类:
编程语言 时间:
2015-04-22 00:01:12
阅读次数:
349
fibonacci数列的性质:
1.gcd(fib(n),fib(m))=fib(gcd(n,m))
证明:可以通过反证法先证fibonacci数列的任意相邻两项一定互素,然后可证n>m时gcd(fib(n),fib(m))=gcd(fib(n-m),fib(m)),递归可
求gcd(fib(n),fib(m))=gcd(fib(k),fib(l)),最后k=l,不然继续递归。K...
分类:
其他好文 时间:
2015-04-21 22:42:35
阅读次数:
258
问题描述:将从1到n这n个整数围成一个圆环,若其中任意2个相邻的数字相加,
结果均为素数,那么这个环就成为素数环。
n=20时,下面的序列就是一个素数环:
1 2 3 4 7 6 5 8 9 10 13 16 15 14 17 20 11 12 19 18
英文名:Prime Ring Problem
解题分析:
对于这样的问题, 我的想法就是首先要判断...
分类:
编程语言 时间:
2015-04-21 22:41:24
阅读次数:
583
Problem AAlmost Prime NumbersTime Limit: 1 secondAlmost prime numbers are the non-prime numbers which are divisible by only a single prime number. In ...
分类:
其他好文 时间:
2015-04-21 20:42:15
阅读次数:
104
http://poj.org/problem?id=3723分析:因为,图可能不连通,求所有最大生成树的总和最大,即最大权森林。prime算法会超内存。 1 #include 2 #include 3 #include 4 #define _Clr(x, y) memset(x, y, sizeo....
分类:
其他好文 时间:
2015-04-21 01:44:58
阅读次数:
129
Problem DescriptionYour task is to calculate the sum of some integers. InputInput contains an integer N in the first line, and then N lines follow. Ea...
分类:
其他好文 时间:
2015-04-20 20:46:06
阅读次数:
133
Problem DescriptionIn this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one ...
分类:
其他好文 时间:
2015-04-20 16:43:17
阅读次数:
94
Problem DescriptionYour task is to Calculate a + b.InputInput contains an integer N in the first line, and then N lines follow. Each line consists of ...
分类:
其他好文 时间:
2015-04-20 16:42:30
阅读次数:
101
Problem DescriptionIn this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one ...
分类:
其他好文 时间:
2015-04-20 16:17:37
阅读次数:
144