๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.63K subscribers
5.6K photos
3 videos
95 files
10.3K 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
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

const int P = 1000000007;

int solve(string N, int K) {
    if (K == 0) {
        return 1;
    }

    int len = N.size();
    int num[1010] = {0};
    int f[1010][1010][2] = {0};
    int ans = 0;

    for (int i = 2; i <= 1000; i++) {
        num[i] = num[__builtin_popcount(i)] + 1;
    }

    f[0][0][0] = 1;

    for (int i = 0; i < len; i++) {
        for (int j = 0; j <= i; j++) {
            for (int k = 0; k < 2; k++) {
                for (int l = 0; l <= (k ? 1 : (N[i] - '0')); l++) {
                    (f[i + 1][j + l][k | (l < N[i] - '0')] += f[i][j][k]) %= P;
                }
            }
        }
    }

    for (int i = 1; i <= 1000; i++) {
        if (num[i] == K - 1) {
            (ans += f[len][i][0]) %= P;
            (ans += f[len][i][1]) %= P;
        }
    }

    if (K == 1) {
        ans = (ans + P - 1) % P;
    }

    return ans;
}

int main() {
    string s;
    int k;
    cin >> s >> k;
    cout << solve(s, k) << endl;
    return 0;
}


Possible decryption โœ…
๐Ÿ‘2
int solve(int x1, int y1, int x2, int y2, int cx, int cy, int R)
{
    int count = 0;
    int R_squared = R * R;
    for (int y = y1; y <= y2; ++y)
    {
        int dy_squared = (y - cy) * (y - cy);
        if (dy_squared > R_squared)
            continue;
        int dx = static_cast<int>(sqrt(R_squared - dy_squared));
        int min_x = std::max(x1, cx - dx);
        int max_x = std::min(x2, cx + dx);
        if (min_x <= max_x)
        {
            count += (max_x - min_x + 1);
        }
    }

    return count;
}

int main()
{

    int x1 = 1, y1 = 1, x2 = 100000, y2 = 100000, cx = 50000, cy = 50000, R = 1000;
    cin >> x1 >> y1 >> x2 >> y2 >> cx >> cy >> R;
    cout << solve(x1, y1, x2, y2, cx, cy, R) << endl;
    return 0;
}

//Cordinates sprinkler โœ…
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
int main() {
    int n, a, b;
    cin >> n >> a >> b;
    map<pair<int, int>, int> slope_map;
    for (int i = 0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        int dy = y - b;
        int dx = x - a;
        int g = gcd(dx, dy);
        dy /= g;
        dx /= g;
        if (dx < 0) {
            dy = -dy;
            dx = -dx;
        } else if (dx == 0) {
            dy = abs(dy);
        }

        slope_map[{dy, dx}]++;
    }
    int aa = 0;
    for (auto &entry : slope_map) {
        int count = entry.second;
        aa += count * (count - 1) / 2;
    }
    cout << aa << endl;
    return 0;
}


MAQ Software โœ…
๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
Photo
#include <bits/stdc++.h>
using namespace std;

bool isVowel(char c) {
    return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
}

vector<int> hasVowels(vector<string>& strArr, vector<string>& queries) {
    int n = strArr.size();
    vector<int> prefix(n + 1, 0);

    for (int i = 0; i < n; i++) {
        bool startsAndEndsWithVowel = isVowel(strArr[i][0]) && isVowel(strArr[i].back());
        prefix[i + 1] = prefix[i] + (startsAndEndsWithVowel ? 1 : 0);
    }

    vector<int> results;
    for (string query : queries) {
        int l, r;
        sscanf(query.c_str(), "%d-%d", &l, &r);

        l--; r--;

        int count = prefix[r + 1] - prefix[l];
        results.push_back(count);
    }

    return results;
}


IBM HASVOWELโœ…
def lotteryCoupons(n):
    count = [0] * 37
    maxCount = 0

    for i in range(1, n + 1):
        digitSum = sum(int(digit) for digit in str(i))
        count[digitSum] += 1
        maxCount = max(maxCount, count[digitSum])

    result = sum(1 for c in count if c == maxCount)
    return result

IBM Lottery with n coupons โœ…
๐Ÿ”ฅ1
class UnionFind:
    def __init__(self, n):
        self.parent = list(range(n))
        self.rank = [0] * n
        self.components = n

    def find(self, x):
        if self.parent[x] != x:
            self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def union(self, x, y):
        px, py = self.find(x), self.find(y)
        if px != py:
            if self.rank[px] < self.rank[py]:
                self.parent[px] = py
            elif self.rank[px] > self.rank[py]:
                self.parent[py] = px
            else:
                self.parent[py] = px
                self.rank[px] += 1
            self.components -= 1

def minOperations(compNodes, compFrom, compTo):
    uf = UnionFind(compNodes + 1)
   
    for u, v in zip(compFrom, compTo):
        uf.union(u, v)
   
    operations = uf.components - 2
    return operations if operations >= 0 else -1

IBM computer networks โœ…
def minimalOperations(words):
    def count_substitutions(word):
        count = 0
        n = len(word)
        i = 0
        while i < n - 1:
            if word[i] == word[i + 1]:
                count += 1
                i += 2
            else:
                i += 1
        return count
    return [count_substitutions(word) for word in words]


IBM โœ