Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n. For example: Given n = 13, Retur...
分类:
其他好文 时间:
2016-01-19 12:02:37
阅读次数:
139
dp[i][j]表示长度i末尾为S[j]的方案数dp[1][0...m-1]=1dp[i][j]=∑dp[i-1][k] (|S[k]-S[j]| 2 #include 3 #include 4 using namespace std; 5 int d[11][11]; 6 int main(){ ...
分类:
其他好文 时间:
2016-01-16 01:16:44
阅读次数:
383
No loop; No recursion; 我没找到规律 但是从讨论区看到别人的思路:IfNis a power of3:It follows that3^X == NIt follows thatlog (3^X) == log NIt follows thatX log 3 == log NI...
分类:
其他好文 时间:
2016-01-15 06:28:22
阅读次数:
251
int letter = 0; int digit = 0; int other = 0; for(NSUInteger i = 0; i 0) && text.length >= 6 && text.length <= 20;判断密码有效性,主要用到了NSCharac...
分类:
其他好文 时间:
2016-01-12 01:16:53
阅读次数:
228
这道题其实挺水,只是写的时候需要想清楚。我的方法是:1.将[a,b]转化为[0,b+1)-[0,a)2.预处理出非0的v在区间[0,10^p)出现次数以及0在区间[0,10^p)出现数3.将一个区间再拆分为几段,如:12345拆分为[0,10000),[10000,12000),[12000,123...
分类:
其他好文 时间:
2016-01-11 20:17:32
阅读次数:
258
Add Digits: Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. For example: Given num = 38, the proc...
分类:
其他好文 时间:
2016-01-11 20:15:25
阅读次数:
175
创建两个数组 分别记录两个字符串 各个位置字符出现的上一个位置 通过比较当前字符的上一个位置是否相同 判断是否同构比较坑爹的是 一开始以为只有字母 所以纠结于怎么找出字母来。。。代码如下:public class IsomorphicStrings { public static boolean ....
分类:
其他好文 时间:
2016-01-11 06:50:17
阅读次数:
203
1 #include 2 #include 3 #define maxn 100005 4 int ans[maxn]; //类似于 比较大的数组还是开导外面比较好一点,防止报错. 5 int main() 6 { 7 int x,y,m,T,n; 8 mems...
分类:
其他好文 时间:
2016-01-05 12:40:55
阅读次数:
130
题目信息1069. The Black Hole of Numbers (20)时间限制100 ms
内存限制65536 kB
代码长度限制16000 BFor any 4-digit integer except the ones with all the digits being the same, if we sort the digits in non-increasing order...
分类:
其他好文 时间:
2015-12-28 12:28:35
阅读次数:
141
Given a non-negative integernum, repeatedly add all its digits until the result has only one digit.For example:Givennum = 38, the process is like:3 + ...
分类:
其他好文 时间:
2015-12-26 22:11:57
阅读次数:
145