my_rand()

· · 个人记录

#include <bits/stdc++.h>

using namespace std;

unsigned long long my_rand() {
    static unsigned long long res = 1;
    unsigned long long x;
    x = (unsigned long long) new char;
    delete (char *) x;
    res *= x & 0xff;
    res += (x << 13) ^ (x >> 7);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for (int i = 0; i < 100; ++i) {
        cout << my_rand() << "\n";
    }
    return 0;
}
#include<bits/stdc++.h>

using namespace std;

unsigned int xor_shift() {
    static unsigned int res = random_device{}();
    res ^= (res << 13);
    res ^= (res >> 17);
    res ^= (res << 5);
    return res;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    for (int i = 0; i < 100; ++i) {
        cout << xor_shift() << " ";
    }
    return 0;
}