We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Number Theory
- Salary Blues
- Discussions
Salary Blues
Salary Blues
Sort by
recency
|
30 Discussions
|
Please Login in order to post a comment
1) The salaries after normalization are actually just the gcd - note the process is reminiscent of the naïve euclidean algorithm, or that it preserves divisors + reduces numbers until everything is equal => everything ends up at an equal number which is divided by every divisor of the original set, which is the gcd
2) gcd(a1+k, a2+k, ..., an+k) = gcd(a1+k, (a2+k)-(a1+k), ..., (an+k)-(a1+k)) = gcd(a1+k, a2-a1, ..., an-a1) = gcd(a1+k, gcd(a2-a1, an-a1)). You can precompute the second bit of the gcd and then you only have to do a gcd with two elements for each of the queries, which is fast enough to pass.
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.
// 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; }
}
int main() { /* Enter your code here. Read input from STDIN. Print output to STDOUT */
}