Or don't use floating point numbers at all. When computing a/b (a,b positive integers), you can use:
a/b - if rounding down
(a+b-1)/b - if rounding up
(2*a+b)/(2*b) - if rounding to the nearest integer (with 0.5 up)
Where / is the integer division.
Search found 30 matches
- Sun Mar 06, 2005 3:09 pm
- Forum: Volume 108 (10800-10899)
- Topic: 10823 - Of Circles and Squares
- Replies: 50
- Views: 17704
- Sat Mar 05, 2005 11:53 pm
- Forum: Volume 108 (10800-10899)
- Topic: 10820 - Send a Table
- Replies: 34
- Views: 19552
- Sat Feb 12, 2005 11:48 pm
- Forum: Other words
- Topic: Programming Contest for Newbies 2005
- Replies: 34
- Views: 8469
- Tue Nov 16, 2004 12:21 am
- Forum: Volume 106 (10600-10699)
- Topic: 10607 - Siege
- Replies: 21
- Views: 8942
- Mon Nov 15, 2004 2:02 am
- Forum: Volume 106 (10600-10699)
- Topic: 10607 - Siege
- Replies: 21
- Views: 8942
Hello guys,
What is your output to this?
My AC program outputs 2, but the answer should be obviously 3 (B and C must be conquered, but they are not bordering, unless I misunderstood the statement).
What is your output to this?
Code: Select all
5 4
DDDD
DBBD
DBAC
DBBD
DDDD
0 0
- Sun Oct 24, 2004 11:59 pm
- Forum: Algorithms
- Topic: Does STL use Boyer-Moore?
- Replies: 2
- Views: 1829
- Sun Oct 24, 2004 11:28 pm
- Forum: Algorithms
- Topic: calculate n choose k
- Replies: 5
- Views: 2666
Re: calculate n choose k
You can use GCD. When computing (A*B)/C, let G=GCD(A,C) thenManiac wrote:but this could overflow because I multiply before I divide. Is there a way to avoid an overflow without factorizing n and m?
(A*B)/C = (A/G) * (B/(C/G)).
- Sun Oct 17, 2004 9:42 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10747 - Maximum Subsequence
- Replies: 15
- Views: 12268
- Sun Oct 17, 2004 8:22 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10745 - Dominant Strings
- Replies: 38
- Views: 23146
- Sun Oct 17, 2004 5:24 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10745 - Dominant Strings
- Replies: 38
- Views: 23146
..: Aren't you checking O(n^2) pairs in the worst case (ie. no dominating strings)? Unless I didn't get your algorithm.
BiK: I was just saying that one string of length K can dominate at most 2^K-2 strings. Since K<=10, one string can dominate at most 1022 strings. So it's cheaper to generate all ...
BiK: I was just saying that one string of length K can dominate at most 2^K-2 strings. Since K<=10, one string can dominate at most 1022 strings. So it's cheaper to generate all ...
- Sun Oct 17, 2004 1:59 pm
- Forum: Volume 107 (10700-10799)
- Topic: 10745 - Dominant Strings
- Replies: 38
- Views: 23146
- Wed May 12, 2004 3:18 pm
- Forum: Volume 2 (200-299)
- Topic: 209 - Triangular Vertices
- Replies: 51
- Views: 11839
- Wed May 12, 2004 12:11 pm
- Forum: Volume 102 (10200-10299)
- Topic: 10207 - The Unreal Tournament
- Replies: 23
- Views: 8759
- Mon May 10, 2004 10:26 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10613 - Mushroom Misery
- Replies: 14
- Views: 7943
- Mon May 10, 2004 7:14 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10613 - Mushroom Misery
- Replies: 14
- Views: 7943