Array Mathematics

Sort by

recency

|

316 Discussions

|

  • + 0 comments

    import numpy

    line=input() n=int(line.split()[0]) m=int(line.split()[1]) a=[] b=[] for i in range(n): m=list(map(int,input().split())) a.append(m)

    a=numpy.array(a)

    for i in range(n): m=list(map(int,input().split())) b.append(m)

    b=numpy.array(b)

    print(a+b) print(a-b) print(a*b) print(a//b) print(a%b) print(a**b)

  • + 0 comments

    import numpy N, M = map(int, input().strip().split()) arr_1 = numpy.array([input().strip().split() for _ in range(N)][:M], dtype=numpy.int_) arr_2 = numpy.array([input().strip().split() for _ in range(N)][:M], dtype=numpy.int_) print(numpy.add(arr_1, arr_2)) #arr_1 + arr_2 print(numpy.subtract(arr_1, arr_2)) #arr_1 - arr_2 print(numpy.multiply(arr_1, arr_2)) #arr_1 * arr_2 print(numpy.floor_divide(arr_1, arr_2)) #arr_1 // arr_2 print(numpy.mod(arr_1, arr_2)) #arr_1 % arr_2 print(numpy.power(arr_1, arr_2)) #arr_1 ** arr_2

  • + 0 comments

    line=input() n=int(line.split()[0]) m=int(line.split()[1]) a=[] b=[] for i in range(n): m=list(map(int,input().split())) a.append(m)

    a=numpy.array(a)

    for i in range(n): m=list(map(int,input().split())) b.append(m)

    b=numpy.array(b)

    print(a+b) print(a-b) print(a*b) print(a//b) print(a%b) print(a**b)

  • + 0 comments
    import numpy
    
    line=input()
    n=int(line.split()[0])
    m=int(line.split()[1])
    a=[]
    b=[]
    for i in range(n):
        m=list(map(int,input().split()))
        a.append(m)
        
    a=numpy.array(a)
    
    for i in range(n):
        m=list(map(int,input().split()))
        b.append(m)
    
    b=numpy.array(b)
       
    print(a+b)
    print(a-b)
    print(a*b)
    print(a//b)
    print(a%b)
    print(a**b)
    
  • + 0 comments

    import numpy as np

    N,M = map(int,input().split()) A =np.array([list(map(int,input().split()))for _ in range(N)]) B = np.array([list(map(int,input().split()))for _ in range(N)])

    print(np.add(A, B)) print(np.subtract(A, B)) print(np.multiply(A, B)) print(np.floor_divide(A, B)) print(np.mod(A, B)) print(np.power(A, B))