题目:Givennpoints on a 2D plane, find the maximum
number of points that lie on the same straight
line.算法分析:定义最大直线为符合相同条件的直线中通过点最多的那条直线。对每个点p,计算其它的点与p形成的...
分类:
其他好文 时间:
2014-05-16 23:26:31
阅读次数:
389
1 #include 2 #include 3 using namespace std; 4
5 int main() 6 { 7 int n; 8 double max,min,sum,aver; 9 double a[110] = {0};10
while...
分类:
其他好文 时间:
2014-05-16 22:47:35
阅读次数:
452
Given a string S, find the longest palindromic
substring in S. You may assume that the maximum length of S is 1000, and there
exists one unique longes...
分类:
其他好文 时间:
2014-05-16 21:15:37
阅读次数:
454
1 #include 2 3 using namespace std; 4 long long p;
5 long long a[20]; 6 long long solve(long long n){ 7 long long left,m,sum =0; 8
for(i...
分类:
其他好文 时间:
2014-05-13 21:29:55
阅读次数:
369
TriangleGiven a triangle, find the minimum path
sum from top to bottom. Each step you may move to adjacent numbers on the row
below.For example, given...
分类:
其他好文 时间:
2014-05-13 18:51:44
阅读次数:
297
题目链接:1350 - Pinary
题意:二进制数,不能有连续的1,给定第n个数字,输出相应的二进制数
思路:先是递推,求出由n位组成的数字中有几个满足条件
dp[i] = dp[i - 1] + dp[i - 2],考虑最后一位放0和倒1位放0的情况。
然后用一个sum[i]记录满足
接着利用二分找到给定的n > sum[i - 1],i的最大值,这个就是所求的答案的最高位。
因为...
分类:
其他好文 时间:
2014-05-13 14:10:44
阅读次数:
246
题意很简单,求sum(gcd(i,n)) 1
这题看到后第一反应并没有里用积性函数的性质,不过也可以做,欣慰的是我反应还是比较快的
设f(n)=gcd(1,n)+gcd(2,n)+....+gcd(n-1,n) + gcd(n,n),
用g(n,i)表示满足 gcd(x,n)=i的 x的个数 (x小于n),则 f(n)=sum{i*g(n,i)};
同时又利用 扩展欧几里德的性...
分类:
其他好文 时间:
2014-05-13 13:40:58
阅读次数:
365
<!doctypehtml>
<html>
<metacharset="utf-8"/>
<head>
<title>益司CMS-PC与手机建站集成</title>
<metaname="viewport"content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<linkrel="stylesh..
分类:
其他好文 时间:
2014-05-13 11:58:21
阅读次数:
335
Prime Ring Problem
Problem Description
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 adjacent...
分类:
其他好文 时间:
2014-05-13 11:54:17
阅读次数:
444
Max Sum of Max-K-sub-sequence
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 5690 Accepted Submission(s): 2059
Problem Description
...
分类:
其他好文 时间:
2014-05-13 11:38:49
阅读次数:
256