Untitled

 avatar
unknown
plain_text
10 months ago
3.7 kB
4
Indexable
#include<bits/stdc++.h>

#define ll long long
#define pp push_back
#define endl '\n'
#define all(x) x.begin(),x.end()
#define ld long double
#define PI acos(-1)
#define sin(a) sin((a)*PI/180)
#define cos(a) cos((a)*PI/180)
#define ones(x) __builtin_popcountll(x)
//#define int ll

using namespace std;

void Drakon() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef Clion
    freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
#endif
}

unsigned long long inf = 1e10;
const double EPS = 1e-6;
const int MOD = 1000000007, N = 200005, LOG = 25;

ll mul(const ll &a, const ll &b) {
    return (a % MOD + MOD) * (b % MOD + MOD) % MOD;
}

ll add(const ll &a, const ll &b) {
    return (a + b + 2 * MOD) % MOD;
}

ll pw(ll x, ll y) {
    ll ret = 1;
    while (y > 0) {
        if (y % 2 == 0) {
            x = mul(x, x);
            y = y / 2;
        } else {
            ret = mul(ret, x);
            y = y - 1;
        }
    }
    return ret;
}

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

struct Book{
    string name, category;
    int pages, price;
};

void solve() {
    for (int i = 0; i < 10; ++i) {
        int t = rnd() % 21 + 10;
        vector<string> vec;
        map<string, Book> books;
        cout << t << endl;
        for (int j = 0; j < t; ++j) {
            int r = rnd() % 2;
            if(!r){
                string user;
                for (int k = 0; k < 3; ++k) {
                    user += rnd() % 26 + 'a';
                }
                int num = rnd() % 10 + 1;
                string bookName;
                int has = rnd() % 2;
                if(vec.empty())has = 0;
                if(!has){
                    for (int k = 0; k < 4; ++k) {
                        bookName += rnd() % 26 + 'a';
                    }
                }
                else{
                    bookName = vec[rnd() % (int)vec.size()];
                }

                int amountPaid = rnd() % 3000 + 1;
                cout << user + " wants to buy " + to_string(num) + " instances of the book " + bookName + " and paid " +
                        to_string(amountPaid) << endl;
            }
            else{
                int num = rnd() % 10 + 1;
                int has = rnd() % 2;
                if(vec.empty())has = 0;
                Book curBook;
                string bookName;
                if(!has){
                    for (int k = 0; k < 4; ++k) {
                        bookName += rnd() % 26 + 'a';
                    }
                    vec.push_back(bookName);
                    string category;
                    for (int k = 0; k < 3; ++k) {
                        category += rnd() % 26 + 'a';
                    }
                    int pages = rnd() % 200 + 1;
                    int price = rnd() % 300 + 1;
                    Book book = {bookName, category, pages, price};
                    curBook = book;
                    books[bookName] = book;
                }
                else{
                    bookName = vec[rnd() % (int)vec.size()];
                    curBook = books[bookName];
                }

                cout << "The shop received " + to_string(num) + " instances of the book " + curBook.name + " " + curBook.category + " " +
                        to_string(curBook.pages) + " " +
                        to_string(curBook.price) << endl;
            }
        }
        cout << endl;
    }
}

signed main() {
    Drakon();
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
}
Editor is loading...
Leave a Comment