brain
tamnd's digital brain — notes, problems, research
41301 notes
Let's carefully analyze the previous Python solution.
Assume first that $u=0$.
Let n = \prod_{p} p^{a_p} be the canonical prime factorization of $n$, where each $a_p \ge 0$ and all but finitely many $a_p$ are zero.
Suppose $1 \le u' < 2^k$ and $1 \le v' < 2^k$, and assume that $\lfloor 2^{2k} u/u' \rfloor = \lfloor 2^{2k} v/v' \rfloor.$ Let $x = 2^{2k} u/u'$ and $y = 2^{2k} v/v'$.
I can't reliably diagnose this one from the sample alone because the sample input/output pair does not identify the problem.
Representing $(1/0)$ and $(-1/0)$ as $\infty$ and $-\infty$ corresponds to adjoining two signed points at infinity to the set of rational numbers.
**Exercise 4.
**Solution.
The recommended division method is the direct fraction-division algorithm.
Let \frac{u}{u'} \div \frac{v}{v'}, where $u \perp u'$ and $v \perp v'$.
Let a=\gcd(u,v'), \qquad b=\gcd(u',v).
The previous solution does not address the exercise at all.
Let d=\gcd(u,v), and define
Let $b$ and $B$ be the bases as in the problem statement.
Let $u = (u_7 \ldots u_1 u_0)_{10}$ be a decimal number, and let $U = (u_7 \ldots u_1 u_0)_{16}$ denote its binary-coded decimal (BCD) representation.
Let u=(u_m u_{m-1}\ldots u_1u_0)_{10} be the decimal number to be converted into binary notation.
Exercise 4.
The error in the previous code is actually two-fold: first, the test harness had a syntax error (a dangling comma in the last `assert`).
The error in the previous code is actually two-fold: first, the test harness had a syntax error (a dangling comma in the last `assert`).
Let the input be an $n$-digit decimal integer N=\sum_{i=0}^{n-1} a_i 10^i, \qquad 0\le a_i\le 9.
**Exercise 4.
Method 1b already provides the key idea.
Let $u$ be a nonnegative integer represented in binary-coded decimal (BCD) form as $u = u_{n-1} u_{n-2} \ldots u_1 u_0,$ where each $u_j$ occupies four bits and satisfies $0 \le u_j \le 9$.
Define v_0(u)=3\lfloor u/2\rfloor+3, and
Equation (5) shows how to replace division by $10$ with multiplication by an approximation to $\frac1{10}$.
Let \delta=r-\alpha .
Methods 1a, 1b, 2a, and 2b are stated for positive radices $b$ and $B$.
**Exercise 4.
A radix conversion routine transforms a nonnegative integer written in one base into its representation in another base.
The statement uses the symbol $\epsilon$ but the data are $u$ and $v$; the intended meaning is that $v$ is the allowed error bound.
Method 1b evaluates u=a_m b_{m-1}\cdots b_0+\cdots+a_1 b_0+a_0 by Horner's rule,
Let the mixed-radix system have radices r_0,r_1,\ldots,r_{n-1}, so that a number is represented in the form
There is actually **no algorithmic bug** in the output you showed.
Let K_1=1,\qquad K_{2n}=3K_n,\qquad K_{2n+1}=2K_{n+1}+K_n \qquad (n\ge1).
The error message is very explicit: `NameError: name 'math' is not defined`.
We restart from a clean formulation and give a model-independent analysis of what “fastest online multiplication” means in each automaton class.
Start with the DFT \hat{u}_t=\sum_{s=0}^{K-1} u_s \,\omega^{st}, \quad \omega=e^{-2\pi i/K}.
**Solution (Corrected)** We are asked to implement the Fourier-transform multiplication method efficiently on a pointer machine and show that $m$-bit multiplication can be done in $O(m)$ steps.
**Exercise 4.
Let the two $n$-bit numbers be A = \sum_{i=0}^{n-1} a_i 2^i, \quad B = \sum_{j=0}^{n-1} b_j 2^j.
**Corrected Solution** We want to show that all complex numbers $A^{(j)}$ computed during the third Fourier transform (the computation of $\tilde{w}_s$) satisfy $|A^{(j)}| < 1$.
The statement is **false**.
Let $U(x)$ and $V(x)$ be polynomials of degree $r$ with integer coefficients, and let $W(x) = U(x)V(x),$ so $W(x)$ has degree at most $2r$.
**Corrected Solution to Exercise 4.
We are asked to track a frog moving along a one-dimensional axis starting at position 0.
Let $\ell(n)$ denote the binary length of $n$, i.
**Corrected Solution for Exercise 4.
**Exercise 4.
This is no longer a Codeforces 1535C input issue.
Thank you, now the issue is fully clear.
Let $x$ be an $n$-digit automorph, so the last $n$ digits of $x^2$ equal $x$.
We are asked to compute w = (uv) \bmod (2^q - 1) for two $q$-bit integers $u$ and $v$ given in the mixed-radix representation
The claimed output `10` for `"0?
Let $m_1, m_2, \ldots, m_r$ be odd integers, and let $u = (u_1, \ldots, u_r)$ satisfy $0 \le u < m$, where $m = m_1 m_2 \cdots m_r$, and suppose that $u$ is even.
From the construction of mixed-radix digits in (25), the integer $u$ is represented in the form u \equiv v_1 + m_1 v_2 + m_1 m_2 v_3 + \cdots + m_1 m_2 \cdots m_{r-1} v_r \pmod{m}, and for each $j$ th...
Suppose an integer $u$ lies in the symmetrical range $-\frac{m}{2} < u < \frac{m}{2}, \qquad m = m_1 m_2 \cdots m_r, \eqno(10)$ and we seek numbers $u_1, \ldots, u_r$ such that $u \equiv u_j \pmod{m_j...
The reviewer is correct that the previous submission is unrelated to the stated TAOCP exercise.
Equation (24) in _The Art of Computer Programming_, Volume 2, Section 4.
The solution does not correctly determine the outcome of the greedy procedure in part (a).
Edit Let m=2^g-1.
Equation (13) is obtained by the rule stated immediately before it.
Let m=\operatorname{lcm}(m_1,m_2,\ldots,m_r).
We are asked whether Theorem C from _The Art of Computer Programming_ would still hold if the variables $a$, $u_1, u_2, \dots, u_r$, and $u$ were allowed to be arbitrary real numbers instead of intege...
Find all integers $u$ satisfying u \equiv 1 \pmod 7, \qquad u \equiv 0 \pmod{11}, \qquad
The desired value of $w$ is the nearest integer to $uv/255$.
Let $u$ be a $2n$-place number and $v$ an $n$-place number in base $b$, with $0 \le u < b^{2n}$, $0 \le v < b^n$, and assume $u = vq$ so the remainder is zero.
Let u_i=(u_{i,n-1}\cdots u_{i,1}u_{i,0})_b, \qquad 0\le u_i<b^n, and let
We are given a directed graph whose vertices are cities and whose root is city 1, the capital.
The solution attempts to prove the lower bound on the true remainder when the trial quotient $\hat q$ underestimates the true quotient $q$ by 1.
Let $x = uv$, where $0 \le u,v < 2^n$.
Let \(\phi\) be given to \(n\) digits of precision in a fixed radix \(b\).
In Algorithm D, step D1 multiplies both the dividend and the divisor by the same power of $b$ so that the leading digit of the divisor satisfies $v_{n-1} \ge \lfloor b/2 \rfloor$.
A correct design must first remove the ambiguity about what “word-level scaling” means and then express every operation in terms of explicit operations on fixed-size word arrays.
A correct solution must design algorithms, not analyze radix transformations.
**Solution to Exercise 4.
Assume first that $v \ne 0$.
In Algorithm A, each digit $w_j$ is computed from the expression $u_j + v_j + k$, where $k$ is the carry from the previous position.
The claim is: > At the beginning of step D3 of Algorithm D, we always have $u_{j+n} = 0$.
**Solution to Exercise 4.
Let $v = (.v_{n-1}\,v_{n-2}\,\ldots v_1\,v_0)_b$ with $v_{n-1} \ne 0$.
Step D8 in Program D performs the correction after an over-subtraction in the trial quotient step of the division algorithm.
**Corrected Solution to Exercise 4.
Section 4.
Let $b,v\in\mathbb{Z}$ with $1\le v<b$.
Let the dividend be $(u_3 u_2 u_1 u_0)_{10} = (8500)_{10}$ and the divisor be $(v_2 v_1 v_0)_{10} = (101)_{10}$.
**Solution to Exercise 4.
Let $u$ and $v$ be positive integers with $n$ digits in base $b$, written in the notation of Exercises 19 and 20: u = u_{n-1} b^{\,n-1} + u_{n-2} b^{\,n-2} + \cdots + u_0, \qquad v = v_{n-1} b^{\,n-1}...
In the setting of Fig.
**Solution to Exercise 4.
The solution correctly addresses the exercise.
The solution correctly addresses the exercise.
We prove the validity of Algorithm M by induction on the outer loop variable $j$, using the method of inductive assertions from Section 1.
Let the multiplicand be stored in memory as U=(u_{n-1}\ldots u_1u_0)_b, with one digit per word, and let $v$ be a single precision number,
Exercise 4.
Exercise 4.
Program S represents the quantity $1+k$ in register A.
Compare the digits beginning with the most significant position.
Exercise 4.
Exercise 5 of section 4.
We are asked to design an algorithm that adds two numbers digit by digit from **most significant to least significant**, producing each output digit only when it cannot possibly be affected by future...