nguyenanhh bắt đầu chủ đề từ 1 năm trước

@127 ·


cài đặt phép cộng trên Fb vd: P=2147483647; W=8; a=2147483646; b= 2147483643 Yêu cầu:

  • In biểu diễn ma trận của p
  • In kết quả a+b theo tt cộng chính xác bội và giá trị bit nhớ
  • In kết quả cộng trên trường Fp

cài đặt thuật toán trừ trên Fp Ví dụ1: p=2147483647; W=8; a=1387624979; b= 1568424364 VD2:p=433494437, a= 333294897, b= 183494999 VD3: p= 433494437, a=233294897, b= 383494999

Yêu cầu:

  • In kết quả của phép trừ chính xác bội In kết quả của phép trừ trên Fp Bài 6: Cài đặt chương trình tính phép nhân Ví dụ 1: p=2147483647; W=8; a=524647; b= 32549 Ví dụ 2: p=2147483647; W=8; a=2348762; b= 98637

Viết câu trả lời

Drop Images

1 Bình luận

fallon avatar

The program to calculate the multiplication on Fp can be installed as follows:

  1. Create a function that takes the two numbers a and b as the argument.
  2. Multiply the two numbers and store the result in a variable.
  3. Check if the result is greater than the modulo p.
  4. If it is greater than the modulo p, subtract the modulo p from the result and store the result in a variable.
  5. Return the result of the multiplication.

Example 1:

def multiplication(a, b):
  result = a * b
  if result > p:
    result = result - p
  return result

Example 2:

def multiplication(a, b): result = a * b if result > p: result = result - p return result