#defineするモッド1000000007 クラスアリ{ パブリック: ベクトル < INT >衝突(int型n)を { int型 = POW(ダウン2.0まで、N)=ダウン2 。 int型の TEMP = GCD(上、下)。 ベクトル < int型 > のres; res.push_back(アップ / 温度); res.push_back(ダウン / TEMP)。 リターンのres; } int型 GCD(int型のx、int型のY) { リターン(!yを)X:?GCD(Y、Xの%のY)。 } }。
クラスRandomP { パブリック: 静的 int型F(); }; クラスRandom01 { パブリック: // 確率RandomP :: F()01の実現返す int型(random01を) { int型A、B、 一方(1 ) { Aが = :: F RandomP(); B = RandomP :: F(); IF(A =!B) リターン(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); } };