标签:ima mod dom png nbsp public ber efi push
#define Mod 1000000007 class Ants { public: vector<int> collision(int n) { int down=pow(2.0,n),up=down-2; int temp=gcd(up,down); vector<int> res; res.push_back(up/temp); res.push_back(down/temp); return res; } int gcd(int x,int y) { return (!y)?x:gcd(y,x%y); } };
class RandomP { public: static int f(); }; class Random01 { public: // 用RandomP::f()实现等概率的01返回 int random01() { int a,b; while(1) { a=RandomP::f(); b=RandomP::f(); if(a!=b) return (a>b)?0:1; } } };
// 以下内容请不要修改 class Random5 { public: static int randomNumber(); }; class Random7 { public: int rand5() { return Random5::randomNumber(); } // 以上内容请不要修改 int randomNumber() { int a=5*(rand5()-1)+rand5()-1; while(a>20) a=5*(rand5()-1)+rand5()-1; return a%7+1; } };
class RandomSeg { public: // 等概率返回[0,1) double f() { return rand() * 1.0 / RAND_MAX; } // 通过调用f()来实现 double random(int k, double x) { double res=-1; for(int i=0;i<k;i++) { double b=f(); res=(res>b)?res:b; } return res; } };
class RandomPrint { public: vector<int> print(vector<int> arr, int N, int M) { vector<int> res; for(int i=0;i<M;i++) { int pos=rand()%(N-i); res.push_back(arr[pos]); swap(arr[pos],arr[N-i-1]); } return res; } };
#define Mod 1000000007 class Championship { public: vector<int> calc(int k) { vector<int> res; int up=1,down=1,i=2*k-1; while(i>0) { down*=i; i=i-2; } i=k+1; while(i>2) { up*=i; i--; } int Com=gcd(down-up,down); res.push_back((down-up)/Com); res.push_back(down/Com); return res; } int gcd(int x, int y) { return (!y)?x:gcd(y,x%y); } };
标签:ima mod dom png nbsp public ber efi push
原文地址:https://www.cnblogs.com/tianzeng/p/11285973.html