Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdint>
- #include <algorithm>
- #include <cmath>
- #include <random>
- using namespace std;
- const int N = 1000;
- const int S = 58;
- const double p = 1-sqrt(0.5);
- uint64_t bottles[N];
- uint64_t deaths[N*(N-1)/2];
- bool check() {
- int k=0;
- for (int i=1;i<N;i++) for (int j=0;j<i;j++) deaths[k++]=bottles[i]|bottles[j];
- sort(deaths,deaths+k);
- return unique(deaths,deaths+k)==deaths+k;
- }
- void draw() {
- static random_device rd;
- static mt19937 gen(rd());
- bernoulli_distribution d(p);
- for (int n=0;n<N;n++) {
- bottles[n]=0;
- for (int s=0;s<S;s++) {
- if (d(gen)) bottles[n] |= (uint64_t(1)<<s);
- }
- }
- }
- void print() {
- for (int s=0;s<S;s++) {
- for (int n=0;n<N;n++) cout<<(bottles[n]&(uint64_t(1)<<s)?1:0);
- cout<<endl;
- }
- }
- int main() {
- int t = 0;
- do {
- draw();
- cout<<"try "<<++t<<endl;
- } while (!check());
- print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement