Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu...
分类:
其他好文 时间:
2014-09-27 23:31:00
阅读次数:
186
#!/usr/bin/envpython
importrandom
importstring
importsys
similar_char=‘0OoiI1LpP‘
upper=‘‘.join(set(string.uppercase)-set(similar_char))
lower=‘‘.join(set(string.lowercase)-set(similar_char))
symbols=‘!#$%&\*+,-./:;=?@^_`~‘
numbers=‘123456789‘
group=(..
分类:
编程语言 时间:
2014-09-27 18:38:20
阅读次数:
192
C语言不要求检查下标的范围。当下标超出范围时,程序可能会执行不可预知的行为。看下这个程序:#include #define N 10 //int main(){ int a[N],i; printf("Enter %d numbers: ",N); for(i=0; i=0;...
分类:
编程语言 时间:
2014-09-27 01:26:59
阅读次数:
222
可以像筛选法那样标记 但是内存最多只能开1024的int数组 我用了位优化 用一个int 32 位标记32个数字 接下来就离线 排个序 算出第k大的哪个数
#include
#include
#include
using namespace std;
int a[10000000/32];
struct node
{
int x, y, id;
}b[50010];
int get(...
分类:
其他好文 时间:
2014-09-26 20:31:58
阅读次数:
162
题意:给定x、y,为[x,y]之间有多少个数的偶数位和减去奇数位和等于一。
个位是第一位。
例子: 10=1-0=1 所以10是这样的数
思路:数位dp[i][sum][ok] i位和为sum 是否含有前导0.
然后就是因为有负数 所以根据范围把0设置为100 然后最后和等于101则为所求的数。
代码:
[cpp]
view plaincopyprint?
#...
分类:
其他好文 时间:
2014-09-26 05:06:08
阅读次数:
228
第一项:重命名对象 execute sp_rename @objname='Nums',@newname ='Numbers',@objtype ='object'; go 这里要特别小心 @newname 这个参数不要带架构 如 :@newname ='dbo.Numbers' 这下就...
分类:
数据库 时间:
2014-09-26 01:00:57
阅读次数:
226
题意:
对于一个数的每个位上的数。
对于每个奇数,如果出现必须出现偶数次。
对于每个偶数,如果出现必须出现奇数次。
思路:
用三进制存储每个数出现的状态,0没出现,1出现奇数次,2出现偶数次。
然后其他和普通数位dp就一样了。
代码:
#include"cstdlib"
#include"cstdio"
#include"cstring"
#include"cmath"
#incl...
分类:
其他好文 时间:
2014-09-25 13:08:28
阅读次数:
240
题目链接A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message c...
分类:
其他好文 时间:
2014-09-25 01:02:47
阅读次数:
240
题目地址:HDU 3117
对于后四位可以用矩阵快速幂快速求出来,但前四位就没办法了。要知道斐波那契数列是有通项公式的,所以只能通过通项公式来求前四位,但公式不能求后四位,因为公式使用浮点数求的,精度显然不够,求前四位要用到对数。
通项公式为:
f(n)=1/sqrt(5)(((1+sqrt(5))/2)^n+((1-sqrt(5))/2)^n)
假设F[n]可以表示成 t * 10^...
分类:
其他好文 时间:
2014-09-24 22:17:08
阅读次数:
249