๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.68K links
๐ŸšฉMain Group - @SuperExams
๐Ÿ“Job Updates - @FresherEarth

๐Ÿ”ฐAuthentic Coding Solutions(with Outputs)
โš ๏ธDaily Job Updates
โš ๏ธHackathon Updates & Solutions

Buy ads: https://telega.io/c/cs_algo
Download Telegram
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define vll vector<ll>

struct SegmentTree {
    ll N;
    vll tree;
    ll neutral = 0;

    ll combine(ll a, ll b) {
        return a + b;
    }

    void build(ll u, ll L, ll R, vll &v) {
        if(L == R) {
            tree[u] = v[L];
        } else {
            ll M = (L + R) / 2;
            build(u * 2, L, M, v);
            build(u * 2 + 1, M + 1, R, v);
            tree[u] = combine(tree[u * 2], tree[u * 2 + 1]);
        }
    }

    SegmentTree(vll v) {
        N = v.size() - 1;
        tree.assign(4 * N + 1, 0);
        build(1, 1, N, v);
    }

    ll query(ll lq, ll rq, ll u, ll L, ll R) {
        if(L > rq || R < lq) {
            return neutral;
        } else if(L >= lq && R <= rq) {
            return tree[u];
        } else {
            ll M = (L + R) / 2;
            return combine(query(lq, rq, u * 2, L, M), query(lq, rq, u * 2 + 1, M + 1, R));
        }
    }

    void update(ll idx, ll val, ll u, ll L, ll R) {
        if(L > idx || R < idx) {
            return;
        } else if(L == R) {
            tree[u] = val;
            return;
        } else {
            ll M = (L + R) / 2;
            update(idx, val, u * 2, L, M);
            update(idx, val, u * 2 + 1, M + 1, R);
            tree[u] = combine(tree[u * 2], tree[u * 2 + 1]);
        }
    }
};

const int MAXN = 1e6 + 1;
vector<int> spf(MAXN);

void sieve() {
    spf[1] = 1;
    for (int i = 2; i < MAXN; i++)
        spf[i] = i;
    for (int i = 4; i < MAXN; i += 2)
        spf[i] = 2;
    for (int i = 3; i * i < MAXN; i++) {
        if (spf[i] == i) {
            for (int j = i * i; j < MAXN; j += i)
                if (spf[j] == j)
                    spf[j] = i;
        }
    }
}

int32_t main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    sieve();
    int n, q; cin >> n >> q;
    vll arr(n + 1);
    for(int i = 1; i <= n; i++) cin >> arr[i];
    SegmentTree sgt(arr);
    set<int> s;
    for(int i = 1; i <= n; i++)
        s.insert(i);

    while(q--) {
        int type; cin >> type;
        int a, b; cin >> a >> b;
        if(type == 3) {
            sgt.update(a, b, 1, 1, n);
            int temp = a;
            auto it = s.lower_bound(temp);
            if(it != s.end() and s.size() != 0 and *it == a) {
                s.erase(temp);
                s.insert(a);
            } else {
                s.insert(a);
            }
            arr[a] = b;
        } else if (type == 2) {
            cout << sgt.query(a, b, 1, 1, n) << endl;
        } else {
            while(a <= b) {
                int temp = a;
                auto it = s.lower_bound(temp);
                if(it == s.end()) break;
                if(*it > b) break;
                int c = *it + 1;
                sgt.update(a, arr[a] / spf[arr[a]], 1, 1, n);
                if(spf[a] == 1) {
                    s.erase(temp);
                }
                arr[a] = spf[a];
                a = c;
            }
        }
    }
    return 0;
}

Divisior queries โœ…
BNY Mellon
Source : Hola
#include <bits/stdc++.h>
using namespace std;

// Function to find the extended GCD
int64_t extendedGCD(int64_t a, int64_t b, int64_t &x, int64_t &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    int64_t x1, y1;
    int64_t gcd = extendedGCD(b, a % b, x1, y1);
    x = y1;
    y = x1 - (a / b) * y1;
    return gcd;
}


int main ()
{
  int64_t a, b; cin >> a >> b;
  int64_t w; cin >> w;
  w *= 1000;
  int64_t x,y;
  int64_t gcd = extendedGCD(a,b,x,y);
  if (w%gcd != 0) cout << -1 << endl;
  else {
    x *= w / gcd;
    y *= w / gcd;
    a /= gcd;
    b /= gcd;
    int64_t lowerbound=ceil(-(double)x/b);
    int64_t upperbound=floor((double)y/a);
    if (lowerbound <= upperbound) {
          int64_t res1 = (x+b*lowerbound) + (y-a*lowerbound);
   int64_t res2 = (x+b*upperbound) + (y-a*upperbound);
   cout << res1 + res2 << endl;
    } else {
      cout << - 1 << endl;
    }
  }

}


Fruit weight combinations โœ…
def romanizer(numbers):
n1 = numbers
final = []
d = {1:'I', 4:'IV', 5:'V', 9:'IX', 10:'X', 40:'XL', 50:'L', 90:'XC', 100:'C', 400:'CD', 500:'D', 900:'CM', 1000:'M'}
for n in n1:
res = ''
while n > 0:
for i, j in reversed(d.items()):
if i <= n:
n -= i
res += j
break
final.append(res)
return final

Python3โœ…
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int M = scanner.nextInt();

        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
        }

        WaxElement(A, N, M);

        scanner.close();
    }

    private static void WaxElement(int[] A, int N, int M) {
        for (int i = 0; i <= N - M; i++) {
            int max = A[i];
            for (int j = 1; j < M; j++) {
                if (A[i + j] > max) {
                    max = A[i + j];
                }
            }
            System.out.print(max + " ");
        }
    }
}
EY India is looking for professionals for their Business Consulting Risk team to execute various engagements, deliverables, internal audits and business-related presentations.

Position: Consultant
Experience: 0-3 years
Qualification: CA/ MBA / CIA / CA Inter

Location: Gurgaon

Interested candidates can comment and share their resume at rishabh.tyagi1@in.ey.com by mentioning subject as "Application for Consultant at EY"