题目链接:http://poj.org/problem?id=1528题目大意:输入一个数n,然后求出约数的和sum,在与这一个数n进行比较,如果sum>n,则输出ABUNDANT,如果sum=n,则输出PERFECT,否则,输出DEFICIENT!注意1的结果是DEFICIENT,0的结果是END...
分类:
其他好文 时间:
2014-07-14 08:59:30
阅读次数:
167
A. LCISTime Limit:2000msCase Time Limit:2000msMemory Limit:32768KB64-bit integer IO format:%I64d Java class name:MainGiven n integers.You have two ope...
分类:
其他好文 时间:
2014-07-13 23:34:39
阅读次数:
272
#include #include int in[9]={1,2,3,4,5,6,7,8,9};int s[9];int re[3][3];int sum(int su[]){ int i,re=0; for(i=0;su[i];i++) re+=su[i]; ret...
分类:
编程语言 时间:
2014-07-13 22:08:59
阅读次数:
342
Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note:
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from ...
分类:
其他好文 时间:
2014-07-13 17:21:40
阅读次数:
208
求1~n内所有数对(x,y),gcd(x,y)=质数,的对数。
思路:用f[n]求出,含n的对数,最后用sum【n】求和。
对于gcd(x,y)=a(设x
他们乘积的f[i*a]值包括i的欧拉函数值。时间复杂度(n*质数个数)
#include
#include
using namespace std;
const int maxx=100010;
int mindiv[maxx+5],p...
分类:
其他好文 时间:
2014-07-13 16:45:50
阅读次数:
177
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.
For example:
Given the below binary tree and sum
...
分类:
其他好文 时间:
2014-07-13 13:58:01
阅读次数:
184
Say you have an array for which the ith element is the price of a given stock on day i.
Design an algorithm to find the maximum profit. You may complete at most two transactions.
Note:
You ma...
分类:
其他好文 时间:
2014-07-13 13:55:14
阅读次数:
305
Design an algorithm and write code to find the first common ancestory of two nodes in a binary tree. Avoid storing additional nodes in data structure....
分类:
其他好文 时间:
2014-07-13 13:24:21
阅读次数:
279
You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of ...
分类:
其他好文 时间:
2014-07-13 13:04:00
阅读次数:
186
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 circles should be a prime...
分类:
其他好文 时间:
2014-07-12 16:42:15
阅读次数:
271