ad hoc math problems
play

Ad Hoc Math Problems Section 5.15.2 Dr. Mayfield and Dr. Lam - PowerPoint PPT Presentation

Ad Hoc Math Problems Section 5.15.2 Dr. Mayfield and Dr. Lam Department of Computer Science James Madison University Nov 20, 2015 More group therapy Some problems are easier than others (see projecteuler.net for even more fun) Nov


  1. Ad Hoc Math Problems Section 5.1–5.2 Dr. Mayfield and Dr. Lam Department of Computer Science James Madison University Nov 20, 2015

  2. More group therapy Some problems are “easier” than others (see projecteuler.net for even more fun) Nov 20, 2015 Ad Hoc Math Problems 2 of 6

  3. Logarithms Definition y = b x ⇔ x = log b ( y ) Properties log b ( xy ) = log b ( x ) + log b ( y ) � x � log b = log b ( x ) − log b ( y ) y log b ( x n ) = n log b ( x ) √ x = log b ( x ) log b n n http://en.wikipedia.org/wiki/Logarithm Nov 20, 2015 Ad Hoc Math Problems 3 of 6

  4. Change of base For any value k : log b ( x ) = log k ( x ) log k ( b ) #include <cmath> log(x) // base e (natural log) log10(x) // base 10 (common log) Exercise 5.2.1 How to compute log b ( x ) in C++? Nov 20, 2015 Ad Hoc Math Problems 4 of 6

  5. Other math tricks Exercise 5.2.2 1 + (int) log10(x) Answer: Number of digits in x Exercise 5.2.3 √ x in C++? How to compute n Answer: Compute x 1 / n ◮ pow(x, 1.0 / n) ◮ exp(log(x) / n) pow(a, b) = exp(log(a) * b) Nov 20, 2015 Ad Hoc Math Problems 5 of 6

  6. Today’s problems ◮ UVa 10281 - Average Speed (distance = speed × time) ◮ UVa 01225 - Digit Counting (extract and count the digits) ◮ UVa 10035 - Primary Arithmetic (count the carry operations) ◮ UVa 10751 - Chessboard (use diagonal as much as possible) ◮ UVa 10940 - Throwing Cards Away II (find with brute force) ◮ UVa 00264 - Count on Cantor (math, grid, pattern) ◮ UVa 00443 - Humble Numbers (try all 2 i × 3 j × 5 k × 7 l , sort) ◮ UVa 00701 - Archeologists Dilemma (count the # of digits) ◮ UVa 00498 - Polly the Polynomial (straightforward evaluation) ◮ UVa 10137 - The Trip (be careful with precision error) Nov 20, 2015 Ad Hoc Math Problems 6 of 6

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend