**Why can I access private variables in the
copy constructor?** >The access modifiers work on **class level**, and not on
object level.That is, two ob...
分类:
编程语言 时间:
2014-05-12 15:06:06
阅读次数:
315
Given two numbers represented as strings,
return multiplication of the numbers as a string.Note: The numbers can be
arbitrarily large and are non-nega...
分类:
其他好文 时间:
2014-05-11 14:35:13
阅读次数:
270
题目链接:11361 - Investigating Div-Sum Property
白书上的例题,不过没有代码,正好前几天写了一题数位DP的题目,这题也就相对轻松了。
dp[i][x][y]表示加到第i位,数字 % k,数位和 % k的组合情况数,那么现在要添加一个0 - 9的数字上去状态转移为
dp[i + 1][(x * 10 + num) % k][(y + num) % k],计...
分类:
其他好文 时间:
2014-05-11 05:23:33
阅读次数:
316
Divide two integers without using
multiplication, division and mod
operator.这道题要AC也不容易,许多基础概念不懂。最后看了答案,自己再做也很难AC。还是要记住一些关键点才行:1.
负数的补码等于反码+1.所以负数取绝对值就...
分类:
其他好文 时间:
2014-05-10 06:52:22
阅读次数:
380
Geometric Sum时间限制:1000ms |
内存限制:65535KB难度:3描述Compute (a + a^2 + … + a^n) mod m.(a+a2+…an)mod输入Three
integers a,n,m.(1≤a,n,m≤10^18)It ends with EOF.输出T...
分类:
其他好文 时间:
2014-05-10 05:01:02
阅读次数:
339
Problem DescriptionThere are N villages, which
are numbered from 1 to N, and you should build some roads such that every two
villages can connect to e...
分类:
其他好文 时间:
2014-05-10 02:28:50
阅读次数:
374
There are two sorted arrays A and B of size m
and n respectively. Find the median of the two sorted arrays. The overall run
time complexity should be ...
分类:
其他好文 时间:
2014-05-09 23:26:18
阅读次数:
353
聪明的办法是想:求前10位,那只要前8位加起来,进2位就OK。本的办法,就是真的加起来,截前面10位。如我。numList
= str.split()sum = 0for i in range(0,len(numList)): sum += int(numList[i][0:50])
p...
分类:
其他好文 时间:
2014-05-09 23:16:32
阅读次数:
350
题目链接
迭代加深搜索思想。
枚举答案K,考虑到能否切出K个木头,那么我们当然选最小的K个来切。
1、对于原材料,我们是首选最大的还是最小的?显然,首选大的能够更容易切出,也更容易得到答案。
2、对于目标木头,我们是优先得到最大的还是最小的?显然,由于K个木头我们都要得到,那么当然先把最大的(最难得到的)先得到,这种搜索策略更优。
3、假设总原材料为all,前K个木头总和为sum,那...
分类:
其他好文 时间:
2014-05-09 21:07:28
阅读次数:
305
N-Queens IThen-queens puzzle is the problem of
placingnqueens on ann×nchessboard such that no two queens attack each
other.Given an integern, return a...
分类:
其他好文 时间:
2014-05-09 20:34:01
阅读次数:
335