由买买提看人间百态

topics

全部话题 - 话题: 2147483647
首页 上页 1 2 (共2页)
l***4
发帖数: 1788
1
来自主题: JobHunting版 - 两整数相除问题
leetcode上的divide integer题,小弟的code总是在2147483647, 1这个case上用时过
长,请高手帮忙挑挑bug 拜谢~
code如下:
int divide(int dend, int dor) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
long dividend=dend;
long divisor=dor;
if(dividend==0||divisor==0)
return 0;
int negate=1;
if(dividend<0){
dividend=-dividend;
negate=-negate;
}
if(divisor<0){
divisor=-divisor;
... 阅读全帖
r******j
发帖数: 92
2
我的方法用来数2147483647的位数就不可以,2147483646就可以。哪位知道为什么吗?
r******j
发帖数: 92
3
可是2147483647不是java中int可以表示的最大的整数吗?没有overflow吧?
c********t
发帖数: 5706
4
来自主题: JobHunting版 - Leetcode 最新题, 搞不懂
目测 似乎有个错 {-2147483648,2147483647} 啥结果?
c********t
发帖数: 5706
5
来自主题: JobHunting版 - Leetcode 最新题, 搞不懂
感觉你和ls有一样的错 测测{-2147483648,2147483647}
如果你过了大case, 也许是leetcode没这样的case, 也许是我错了
d*******3
发帖数: 58
6
来自主题: JobHunting版 - 问一道题目。。
@recursive 和@fatalme的蠕虫算法好,我试着写了下
struct Tuple
{
int val;
char from;//A,B,or C
};
int MinAbsDiff(vectr& A,vector& B,vector& C)
{
sort(A.begin(),A.end());
sort(B.begin(),B.end());
sort(C.begin(),C.end());
vector D = Merge(A,B,C);
int findCount[3]={0};
int count = 0;
int ans = 2147483647;
for(int start =0,end =0;end < D.length();end++)
{
if(findCount[D[end].from-'A'] == 0)count++:
findCount[D[end].from-'A']++;
... 阅读全帖
g***j
发帖数: 1275
7
来自主题: JobHunting版 - Divide Two Integers
Divide two integers without using multiplication, division and mod operator.
这个题目怎么做呀,我用的是数学公式exp(logx - logy)
但是,large set就这一个通不过,难道这个除出来不是-1么?他说expected是0,这是
为什么?
2147483647, -2147483648 -1 0
r*c
发帖数: 167
8
来自主题: JobHunting版 - 问一道题(6)
贴个pattern字符串有重复字符的解法, 是dek,cpp1等大牛的解法的扩展。
#include
#include
#include
#include
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN -2147483648
class MinWindowSolution
{
public:
struct TreeNode
{
TreeNode *parent;
int val;
vector children;
TreeNode(int i, TreeNode *p) : val(i), parent(p){}
};
void FindMinWindow_Tree(const vector& input , const vector&
query , int& nStart,... 阅读全帖
r******l
发帖数: 10760
9
来自主题: JobHunting版 - 最快的方法看一个int is a power of two
你这么算的话,几乎所有问题都可以算是O(1)的了。因为精度有限制,即使O(2^n)这种
指数级的复杂度,其实也不会超过2^2147483647这个常数(假设n是32位整数)。
h******o
发帖数: 6
10
bool helper(TreeNode *node, int min, int max) {
if (node == nullptr) return true;
return node->val < max && node->val > min && helper(node->left, min
, node->val) && helper(node->right, node->val, max);
}
bool isValidBST(TreeNode *root) {
if (root && (root->val == INT_MIN || root->val == INT_MAX)) {
if (!root->left && !root->right) {
return true;
}
}
return helper(root, INT_MIN, INT_MAX);
}
fail {-21... 阅读全帖
s******3
发帖数: 61
11
来自主题: JobHunting版 - 请问LC上一道题:Validate BST
原先的OJ很容易通过,
public class Solution {
public boolean isValidBST(TreeNode root) {
return rec(root, Integer.MIN_VALUE, Integer.MAX_VALUE);
}

public boolean rec(TreeNode root, int min, int max) {
if (root == null) return true;

if (root.val <= min || root.val >= max) return false;

return rec(root.left, min, root.val) && rec(root.right, root.val,
max);
}
}
但现在OJ加了新的test case,会有
Input: {2147483647}
Output: false
Expected: tr... 阅读全帖
S*******C
发帖数: 822
12
来自主题: JobHunting版 - 有些面试官也是半桶水
今天面试一个挺高大上的公司,一个韩国面试官让我实现一个HashMap class
我把Entry写成 static inner class
他说应该写成 static inner interface
但HashMap JDK 源代码中的确是写成 static inner class来implement Map.Entry
inner interface的,这个面试官根本没看过源代码,他说要写成static inner
interface的原因仅仅是他找到存在Map.Entry这个interface的api
还有一个问题,我写了一个简洁的hashcode()方法
private int hash(K key){
int hashcode = key.hashCode();
return hashcode > 0 ? hashcode % table.length : -hashcode % table.
length;
}
他说hash怎么可能是负的,为什么要写这个判断语句
实际上
sometimes the hashcode calcul... 阅读全帖
T*****u
发帖数: 7103
13
来自主题: JobHunting版 - Help...leetcode divide two integers
Leetcode divide two integers
why ???
Submission Result: Wrong Answer

Input:
-2147483648, -1

Output:
2147483648

Expected:
2147483647

z*****6
发帖数: 29
14
来自主题: JobHunting版 - Help...leetcode divide two integers
Return value定义的是int吧,int范围是-2147483648 ~ 2147483647的。
你的答案其实算是overflow了吧。
j**********3
发帖数: 3211
15
来自主题: JobHunting版 - 用python写leetcode,sys.maxint怎么办?
是9223372036854775807呢还是2147483647?
我的sys.maxint是长的那个,于是,我自己设了一个max_value。。。囧
http://stackoverflow.com/questions/8164832/python-sys-maxint-sy
大家有好的解决方案嘛?
n*********u
发帖数: 1030
16
来自主题: JobHunting版 - 用python写leetcode,sys.maxint怎么办?
正常写python根本不需要管这个,python自动handle int,long。
leetcode直接define个2147483647就行了。
z*********n
发帖数: 1451
17
来自主题: JobHunting版 - IT certification vs degree vs 刷题
PhD 有用,越牛越有用,牛PhD会刷题,基本奔着800K(我是本版第一个提出此magic
number的人吗?)去了。
认证的作用是1的话,PhD+刷题 作用大概是2147483647吧。
d**********0
发帖数: 13081
l**********9
发帖数: 850
l******a
发帖数: 181
b******n
发帖数: 4559
21
三个小时都得看字幕,忒累了。
另外外国人审美好奇怪,脸上有雀斑也就罢了,已经习惯了,还算是可爱。整个蓝头发
女生牙齿中间缝隙好大啊
箍牙弄整齐了在西方应该还是很基本的吧?
http://cdn.indiewire.com/dims4/INDIEWIRE/07ec106/2147483647/thumbnail/680x478/quality/75/?url=http%3A%2F%2Fd1oi7t5trwfj5d.cloudfront.net%2F57%2F2d%2F252b85ab422f9e460e3a8096de13%2Flea-seydoux-in-blue-is-the-warmest-color.jpg
t*Q
发帖数: 7840
22
来自主题: Joke版 - 神~~
【 以下文字转载自 sysop 讨论区 】
发信人: tPQ (doji), 信区: sysop
标 题: 神~~
发信站: BBS 未名空间站 (Sun Apr 4 07:20:22 2010, 美东)
veron (贝隆) 共上站 61631 次,发表过 2147483647 篇文章
上次在 [Sun Apr 4 07:17:26 2010] 从 [173.225.] 到本站一游。
离线时间[因在线上或非常断线不详] 信箱:[ ] 身份: [用户]
伪币: [0.00](可用:0.00)
经验值:[0](无人问津) 表现值:[348649](神~~) 生命力:[6666]。
目前在站上,状态如下:
主菜单[2]
没有个人说明档
c*******o
发帖数: 27734
23
来自主题: Joke版 - 神~~
哈哈,2147483647 = 7FFFFFFF。看来是溢出了?
M******n
发帖数: 43051
24
bug?
veron (贝隆) 共上站 66741 次,发表过 2147483647 篇文章
上次在 [Mon Dec 10 00:17:35 2012] 从 [66.] 到本站一游。
离线时间[Mon Dec 10 00:30:43 2012] 信箱:[ ] 身份: [用户]
伪币: [0.00](可用:0.00)
经验值:[0](无人问津) 表现值:[321932](神~~) 生命力:[6666]。
没有个人说明档
p****t
发帖数: 4256
25
2^31 -1=2147483647
k**l
发帖数: 2966
26
或者是个 unique ID counter ?你是有史以来地第 2147483647 个人
kx
发帖数: 16384
27
来自主题: Thoughts版 - 给大家介绍一位神人
iMacadamia (aka macadamia) 共上站 18 次,发表过 2147483647 篇文章
上次在 [Wed Jun 17 17:19:17 2009] 从 [71.185.] 到本站一游。
离线时间[Wed Jun 17 18:28:04 2009] 信箱:[信] 身份: [用户]
伪币: [9.70](可用:9.60)
经验值:[0](新手上路) 表现值:[1193046485](神~~) 生命力:[730]。
没有个人说明档
b*****l
发帖数: 9499
28
【 以下文字转载自 Joke 讨论区 】
发信人: bigsail (当年的红帆船), 信区: Joke
标 题: Re: 我操,我的文章数糟糕了 (转载)
发信站: BBS 未名空间站 (Wed Sep 9 12:37:26 2009, 美东)
veron (贝隆) 共上站 9141 次,发表过 2147483647 篇文章
上次在 [Wed Sep 9 12:34:12 2009] 从 [166.111.] 到本站一游。
离线时间[因在线上或非常断线不详] 信箱:[ ] 身份: [用户]
伪币: [0.50](可用:0.00)
经验值:[0](一介白衣) 表现值:[2349320](神~~) 生命力:[6666]。
目前在站上,状态如下:
主菜单[2]
没有个人说明档
b*****l
发帖数: 9499
29
来自主题: Thoughts版 - Re: 我操,我的文章数糟糕了
【 以下文字转载自 sysop 讨论区 】
发信人: EUV (白喜欢潇潇雨了,我恨joke版主), 信区: sysop
标 题: Re: 我操,我的文章数糟糕了
发信站: BBS 未名空间站 (Wed Sep 9 14:49:33 2009, 美东)
2^31 -1 = 2147483647
上,
b********e
发帖数: 74
30
来自主题: Database版 - SQL Server 安装问题请教
想重装SQL Server 2005 developer edition. 不知为什么出现错误.无法安装OWC11.
好像是无法安装Office 2003 Web Components. Google了半天也不知道为什么.请教一
下这里的大牛.
=== Verbose logging started: 4/17/2014 20:26:58 Build type: SHIP UNICODE 3
.01.4001.5512 Calling process: C:Program FilesMicrosoft SQL Server90Setup
Bootstrapsetup.exe ===
MSI (c) (04:0C) [20:26:58:156]: Resetting cached policy values
MSI (c) (04:0C) [20:26:58:156]: Machine policy value 'Debug' is 0
MSI (c) (04:0C) [20:26:58:156]: ******* RunEngine:
******* Pro... 阅读全帖
m******t
发帖数: 2416
31
来自主题: Java版 - help about bitstream writer

JLS 4.2.1: "For int, from -2147483648 to 2147483647, inclusive".
b******a
发帖数: 215
32
2147483647和3147483647换成string,是不是一样的位数?
但是后面那个数已经超出32bit int的范围了.
g*********s
发帖数: 1782
33
来自主题: Programming版 - 经典题atoi的溢出处理 (转载)
【 以下文字转载自 JobHunting 讨论区 】
发信人: gandjmitbbs (Nothing), 信区: JobHunting
标 题: 经典题atoi的溢出处理
发信站: BBS 未名空间站 (Tue Feb 22 21:40:03 2011, 美东)
int atoi(const char* s);
assuming INT_MAX = 2^31-1, INT_MIN = -2^31, the following must hold:
atoi("2147483648") = 2147483647
atoi("-2147483649") = -2147483648
but this seems a little tricky. any elegant solution to handle the
overflow?
k**********g
发帖数: 989
34
来自主题: Programming版 - int 和 unsigned int 比大小会出问题 c++

Firstly, signed and unsigned int have a "common interval".
From zero to INT_MAX (0 .. 2147483647)
When both operands are within this common interval, comparison result will
be correct regardless of each operand's type, and/or the coercion rule.
Therefore, one only needs to check that each operand's value is within this
common interval (prior to coercion). This is how the machine code is
typically generated in languages that have integer range checking.
It is very simple to test this. Just test ... 阅读全帖
k**********g
发帖数: 989
35
来自主题: Programming版 - int 和 unsigned int 比大小会出问题 c++

Firstly, signed and unsigned int have a "common interval".
From zero to INT_MAX (0 .. 2147483647)
When both operands are within this common interval, comparison result will
be correct regardless of each operand's type, and/or the coercion rule.
Therefore, one only needs to check that each operand's value is within this
common interval (prior to coercion). This is how the machine code is
typically generated in languages that have integer range checking.
It is very simple to test this. Just test ... 阅读全帖
l******9
发帖数: 579
36
我不是这个 application 的开发人。
我知道 REST and SOAP.
但是不知道如何在代码里区分它们, REST 只是一种 architectural style。 SOAP
只是一种 protocol 。
我的 application service (published by IIS 7。5 to my desktop)
发布成功后, 交给用户的是一个 URL 指向我的 desktop 的一个文件夹。
用户可以从这个链接 下载并安装 这个 application 工具。 这个工具 有GUI, 可以
从的指向的文件夹 下载文件。
但是, 文件大于 64KB 就不能下载 或者只下载 64KB。
I got error:
connection was forcibly closed by remote server
on my laptop (client side), and
error 504 gateway timeout
on my desktop (server side).
我在IIS 7.5 manager, ASP property 里面 更改了
... 阅读全帖
k******n
发帖数: 184
37
+2147483647
o****e
发帖数: 536
38
来自主题: EE版 - Need help!
Problem statement:
We often use a phase locked loop capable of generating a new frequency which
is locked in
phase to a clock that is supplied at a different frequency. The relationship
between the two
frequencies is given by a rational fraction - that is, there is a
multiplication step and a
division step, both of which are integers, to convert from one frequency to
the other.
For example, we may have a 10 MHz clock, and we need a 12 MHz clock which is
phase
locked to the 10 MHz clock. In this ... 阅读全帖
h**********c
发帖数: 4120
39
来自主题: Mathematics版 - 小朋友的趣味题(包子奖励)
D:\indexpermutation\Debug>indexpermutation
Signed int min: -2147483648 max: 2147483647
total: 253955520
====1,2,3,4,5,6,7,
44__8__-14
7__-18__23__26
-13__22__1__2__26
26__3__4__5
25__6__7
EQ1: 38
EQ2: 38
EQ3: 38
EQ4: 38
EQ5: 38
EQ6: 38
EQ7: 38
EQ8: 38
EQ9: 38
EQ10: 38
EQ11: 38
EQ12: 38
EQ13: 38
EQ14: 38
EQ15: 38
h**********c
发帖数: 4120
40
来自主题: Mathematics版 - 小朋友的趣味题(包子奖励)
1到P^7_{19}的全部解:
D:\indexpermutation\Debug>indexpermutation
Signed int min: -2147483648 max: 2147483647
total: 253955520
Progress 10000000:
True 18064122
Results
15,13,10,14,8,
4,12,9,6,5,
2,16,11,1,7,
19,18,17,3,
True 19273415
Results
15,14,9,13,8,
6,11,10,4,5,
1,18,12,2,7,
17,16,19,3,
Progress 20000000:
Progress 30000000:
Progress 40000000:
Progress 50000000:
Progress 60000000:
Progress 70000000:
Progress 80000000:
True 87367097
Results
16,12,10,19,2,
4,13,3,7,5,
8,15,17,1,6,
14,18,11,9,
True 8
b********r
发帖数: 7843
41
来自主题: sysop版 - 别琢磨技术了,抓人要紧
早抓住了,而且已经正法了
iMacadamia (aka macadamia) 共上站 18 次,发表过 2147483647 篇文章
上次在 [Wed Jun 17 17:19:17 2009] 从 [71.185.] 到本站一游。
离线时间[Wed Jun 17 18:28:04 2009] 信箱:[信] 身份: [新人]
伪币: [9.70](可用:9.60)
经验值:[0](新手上路) 表现值:[1193046485](神~~) 生命力:[29]。
没有个人说明档
t*Q
发帖数: 7840
42
来自主题: sysop版 - 神~~
veron (贝隆) 共上站 61631 次,发表过 2147483647 篇文章
上次在 [Sun Apr 4 07:17:26 2010] 从 [173.225.] 到本站一游。
离线时间[因在线上或非常断线不详] 信箱:[ ] 身份: [用户]
伪币: [0.00](可用:0.00)
经验值:[0](无人问津) 表现值:[348649](神~~) 生命力:[6666]。
目前在站上,状态如下:
主菜单[2]
没有个人说明档
w*******y
发帖数: 60932
43
Today only! 50% off all Neutrogena and Neutrogena Cosmetics at Soap.com. Use
code NG50 at checkout. Max discount $10.
Put $25 worth of Neutrogena and whatever fillers you want use code and it
will take 50% off all Neutrogena products plus you will get free shipping!!
Link:
http://www.soap.com/product/searchresults.aspx?freetext=neutrogena&queryfrom=search&SortExpression=Price (Ascending)&PageSize=2147483647
w*******y
发帖数: 60932
44
Today's Steal - 50% off EAS Myoplex / AvantEdge. No code necessary. Offer
valid while promotional supplies last
Link:
http://www.soap.com/product/searchresults.aspx?freetext=easpromofall&queryfrom=search&viewheader=n&utm_source=social&utm_medium=facebook&PageSize=2147483647&SortExpression=Price (Ascending
)
F/s with $25
w*******y
发帖数: 60932
45
Diapers.com
Today's Deal - 25% off Carter's Multi-Pack Bodysuits.
CartersBodyS uits:
http://www.diapers.com/product/subcategory.aspx?categoryid=9&categoryname=Clothing & Shoes&subcategoryid=182&subcategoryname=Bodysuits&queryfrom=subcategory&filtername=Type|Brand&filtervalue=Multi-pack Bodysuits|Carter's&PageSize=2147483647
Use code FBOCTCARTERS at checkout for 25% off
Add a filler for $0.19c from soap.com and get free shipping on $25 before
the coupon code
VicksCoughDr ops:
http://www.soap.co... 阅读全帖
w*******y
发帖数: 60932
46
Sunday Only!
Buy one Robeez item, get one for 50% off.
Use code FBROBEEZ at checkout.
Valid for 10/31/2010 only while promotional supply lasts.
Cannot be combined with any other offer.
Robeez Shoes:
http://www.diapers.com/product/category.aspx?categoryid=9&categoryname=Clothing & Shoes&queryfrom=category&filtername=Brand&filtervalue=Robeez&PageSize=2147483647&SortExpression=Price (Ascending)
Select the 2 pairs you want add them to your cart then add the filler from
soap.com below to get free shi... 阅读全帖
w*******y
发帖数: 60932
w*******y
发帖数: 60932
48
Save 50% off Garnier Fructis and Garnier Nutrisse at Soap.com.
Use code FBGARNIER at checkout.
Garnier products:
http://www.soap.com/product/searchresults.aspx?freetext=Garnier&queryfrom=search&PageSize=2147483647&SortExpression=Price (Ascending)
Free shipping @ $25 pre-coupon
Valid 12/9/2010 only or while supplies last. Max discount $15. Other
restrictions may apply
w*******y
发帖数: 60932
49
50% off Febreze at Soap.com.
Use code FBFEBREZE at checkout.
Max discount $10
Febreze Products:
http://www.soap.com/product/category.aspx?categoryid=66&categoryname=Household Products&queryfrom=category&filtername=Brand&filtervalue=Febreze&PageSize=2147483647&SortExpression=Price (Ascending)
Valid 12/22/2010 only, while supplies last. .
Cannot be combined with any other offers. Other restrictions apply.
w*******y
发帖数: 60932
50
50% off Clif Bar at Soap.com.
Use code FBCLIF at checkout.
Max discount $10
Clif Products Link:
http://www.soap.com/product/category.aspx?categoryid=74&categoryname=Diet & Fitness&queryfrom=category&filtername=Brand&filtervalue=Clif&PageSize=2147483647&SortExpression=Price (Ascending)
Free shipping @ $25 pre-coupon
Valid 12/28/2010 only, while supplies last.
Cannot be combined with any other offers. Other restrictions may apply
Examples:-
6 x 6 packs (36 total) of Clif Kid Z Bar:
http://www.soap... 阅读全帖
首页 上页 1 2 (共2页)