Sort by

recency

|

28 Discussions

|

  • + 0 comments

    Actors' salaries are often a topic of debate. Like in HackerX, equalizing salaries may avoid disputes. However, industry norms and individual agreements must be considered to ensure fairness.

  • + 0 comments

    I appreciate the detailed explanation and the use of the gcd identities. However, could you elaborate on how the constant time update is achieved in practical scenarios? Are there specific applications or examples where this approach is particularly advantageous? I'm curious to understand the real-world implications of applying these identities to reduce computation time.

  • + 0 comments

    // C++ 20........solution

    const int N = 100000; long long arr[N];

    long long gcd(long long a, long long b) { if(a < 0){ a = -a; }

    if(b < 0){
        b = -b;
    } 
    
    if(b>0){
          return gcd(b, a % b);
    
    }
    else{
        return a;
    }
    

    }

    int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */

    int n, q; 
        cin >> n;
        cin>> q;
    long long int  x;
    
    
    for(int i = 0; i < n; ++i) {
      cin >> x;
      arr[i] = x;
    }
    
    
    long long int  d = 0;
    
    for(int i = 0; i < n; ++i)
        d = gcd(d, arr[i] - arr[0]);
    
    while(q>0)
    {
        int k; cin >> k;
        cout << gcd(d, arr[0] + k) << '\n';
                q--;
    }
    
        return 0;
        }
    
    
    
    return 0;
    

    }

  • + 0 comments

    SPOILER SOLUTION

    from math import gcd
    from functools import reduce
    
    n, q = map(int, input().split())
    arr = list(map(int, input().split()))
    ans = reduce(gcd, arr)
    for _ in range(q):
        offset = int(input())
        if ans != arr[0]:
            print(gcd(ans, offset))
        else:
            print(ans+offset)
    
  • + 0 comments

    Does anyone know what is the exact amount of salary tal dilian gives to their employes?