int_ip = lambda x: '.'.join([str(x/(256**i)%256) for i in range(3,-1,-1)])ip_int = lambda x:sum([256**j*int(i) for j,i in enumerate(x.split('.')[::-1]...
分类:
编程语言 时间:
2014-07-06 21:21:30
阅读次数:
281
既然将这道题分类到动态规划的题目里面,一开始便是用动态规划的思想去思考。一个上午毫无突破,看的人家的题解。定义四个伪指针存放下标,分别表示的意思是在已知的丑数中,能够与2,3,5,7相乘的最小的数的下标。上面这句话要好好体会。也就是说dp[p1] * 2 能够得到一个新的丑数,其他三个以此类推。但我...
分类:
其他好文 时间:
2014-07-06 20:41:32
阅读次数:
223
Divide an array into the maximum number of same((-))sized blocks, each of which should contain an index P such that A[P - 1] A[P + 1].
分类:
其他好文 时间:
2014-07-06 15:30:31
阅读次数:
465
Find the maximum number of flags that can be set on mountain peaks.
分类:
其他好文 时间:
2014-07-06 15:07:09
阅读次数:
371
def IsContinuous(seq, num = 5):
zeros = 0; d = 0
seq = sorted(seq)
for i in range(num - 1):
if seq[i] == 0:
zeros += 1
continue
if seq[i] == seq[i + 1]:
return False
d += seq[i + 1]...
分类:
其他好文 时间:
2014-07-04 07:11:20
阅读次数:
171
#encoding=utf-8
#这是一个易经的启卦程序,在windows下的python3.3下创建‘
#启卦要本着易的四原则,无事不占,不动不占,无疑不占.不能乱占。
importrandom
banyao=range(1,385)
#获取1到384的随机数。
fz=[]
#爻的阴阳列表
fx=[]
#爻符列表
fy=["初","二","三","四","五","..
分类:
编程语言 时间:
2014-07-04 06:42:35
阅读次数:
500
步骤/方法
分三个步骤
在头文件中声明函数例如
afx_msg void onNum(UINT uID)
在.cpp文件中添加函数体
void CCalculatorDlg::OnNum(UINT uID)
{
UINT index=uID-IDC_NUM_0;
CString num;
num.Format(_T("%d"),index);
A...
分类:
其他好文 时间:
2014-07-04 00:38:58
阅读次数:
307
题目链接:uva 11105 - Semi-prime
H-numbers
题目大意:H-number为4?k+1(k为非负数),H-composites为因子中含有H-number(不包括自己本身)的数,反之久是H-prime,给定n,求有多少H-composites。
解题思路:首先用筛选法求出范围内的H-prime,然后枚举两个判断乘积是否在范围内。
#include
#...
分类:
其他好文 时间:
2014-07-04 00:26:37
阅读次数:
248
题目链接:uva 10539 - Almost Prime Numbers
题目大意:给出范围low~high,问说在这个范围内有多少个数满足n=pb,(p为素数).
解题思路:首先处理出1e6以内的素数,然后对于每个范围,用solve(high)?solve(low?1),solve(n)用来处理小于n的满足要求的数的个数。枚举素数,判断即可。
#include
#include...
分类:
其他好文 时间:
2014-07-03 16:50:09
阅读次数:
190
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.int key[]={1000, 900, 500, 400, 100,90, 50, ...
分类:
其他好文 时间:
2014-07-03 12:06:47
阅读次数:
186