๐—–๐—ฆ ๐—”๐—น๐—ด๐—ผ ๐Ÿ’ป ๐ŸŒ ใ€Ž๐—–๐—ผ๐—บ๐—ฝ๐—ฒ๐˜๐—ถ๐˜๐—ถ๐˜ƒ๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ด๐—ฟ๐—ฎ๐—บ๐—บ๐—ถ๐—ป๐—ดใ€
9.52K subscribers
5.56K photos
3 videos
95 files
9.69K 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 <iostream>
#include <vector>

class Stock {
private:
    int S;
    std::vector<int> days;

public:
    Stock(int s, int maxDay) {
        S = s;
        days.resize(maxDay + 1, 0);
    }

    void UpdateDividend(int prevD, int A, int D) {
        if (prevD != -1) {
            for (int i = prevD; i < days.size(); i++) {
                days[i] += A;  // undo previous dividend update
            }
        }
        for (int i = D; i < days.size(); i++) {
            days[i] -= A;
        }
    }

    int CalculateFuturePrice(int F) {
        return S + days[F];
    }
};

int main() {
    int S, N, Q;
    std::cin >> S >> N >> Q;

    Stock stock(S, 1000000); 
    std::vector<int> prevDays(N, -1);
    for (int i = 0; i < N; i++) {
        int A, D;
        std::cin >> A >> D;
        stock.UpdateDividend(-1, A, D);
        prevDays[i] = D;
    }

    for (int i = 0; i < Q; i++) {
        std::string operation;
        std::cin >> operation;

        if (operation == "PRICE") {
            int F;
            std::cin >> F;
            std::cout << stock.CalculateFuturePrice(F) << "\n";
        } else if (operation == "DIVIDEND_UPDATE") {
            int index, A, D;
            std::cin >> index >> A >> D;
            index--; 
            stock.UpdateDividend(prevDays[index], A, D);
            prevDays[index] = D;
        }
    }

    return 0;
}

optiver C++โœ…
#include<iostream>
#include<string>
#include<cmath>

using namespace std;

bool isVowel(char ch) {
    if(ch == 'a' ch == 'e' ch == 'i' ch == 'o' ch == 'u') {
        return true;
    }
    return false;
}

int main() {
    string Str;
    cin >> Str;

    string binaryString = "";
    for(char ch : Str) {
        if(isVowel(ch)) {
            binaryString += '0';
        } else {
            binaryString += '1';
        }
    }
    int decimalValue = 0;
    int n = binaryString.length();

    for(int i = 0; i < n; i++) {
        if(binaryString[i] == '1') {
            decimalValue += pow(2, n - i - 1);
        }
    }
    cout << decimalValue << endl;

    return 0;
}

Providence C++โœ