const int N = 1e5 + 5 ;
const int M = 313 ;
const int P = 1e9 + 7 ;
int D[ N] [ M] ;
const int K = 303 ;
int split[ K] [ K] ;
int fac[ N] ;
int spow( int a, int b) {
int r = 1 ;
while ( b) {
if ( b % 2 ) {
r = r * a % P;
}
a = a * a % P;
b / = 2 ;
}
return r;
}
int Inv( int a) {
return spow( max( a, 1ll) , P - 2 ) ;
}
int inv[ N] ;
void Init( ) {
D[ 0 ] [ 0 ] = 1 ;
fac[ 0 ] = 1 ;
inv[ 0 ] = 1 ;
RE ( n, N - 1 ) {
inv[ n] = Inv( n) ;
D[ n] [ 0 ] = 1 ;
fac[ n] = n * fac[ n - 1 ] % P;
}
RE ( m, M - 1 ) {
int sum = ( m == 1 ) ;
RE ( n, N - 1 ) {
D[ n] [ m] = sum * inv[ n] % P;
sum = ( sum + D[ n] [ m - 1 ] + D[ n] [ m] ) % P;
}
}
split[ 0 ] [ 0 ] = 1 ;
RE ( got, K - 1 ) {
RE ( nonzero, K - 1 ) {
split[ got] [ nonzero] = ( split[ got - 1 ] [ nonzero] + split[ got - 1 ] [ nonzero - 1 ] ) * nonzero % P;
}
}
}
class CyclesNumber {
public :
#undef int
vector < int > getExpectation( vector < int > n, vector < int > m) {
vector< int > res;
#define int long long
Init( ) ;
for ( int i = 0 ; i < SZ( n) ; i++ ) {
int sum = 0 ;
debug( m[ i] ) ;
FOR ( j, 0 , m[ i] ) {
sum + = split[ m[ i] ] [ j] * D[ n[ i] ] [ j] % P * fac[ n[ i] ] % P;
}
res.PB ( sum % P) ;
}
return res;
}
} ;
Y29uc3QgaW50IE4gPSAxZTUgKyA1Owpjb25zdCBpbnQgTSA9IDMxMzsKY29uc3QgaW50IFAgPSAxZTkgKyA3OwppbnQgRFtOXVtNXTsKY29uc3QgaW50IEsgPSAzMDM7CmludCBzcGxpdFtLXVtLXTsKaW50IGZhY1tOXTsKaW50IHNwb3coaW50IGEsIGludCBiKSB7CiAgaW50IHIgPSAxOwogIHdoaWxlIChiKSB7CiAgICBpZiAoYiAlIDIpIHsKICAgICAgciA9IHIgKiBhICUgUDsKICAgIH0KICAgIGEgPSBhICogYSAlIFA7CiAgICBiIC89IDI7CiAgfQogIHJldHVybiByOwp9CmludCBJbnYoaW50IGEpIHsKICByZXR1cm4gc3BvdyhtYXgoYSwgMWxsKSwgUCAtIDIpOwp9CmludCBpbnZbTl07CnZvaWQgSW5pdCgpIHsKICBEWzBdWzBdID0gMTsKICBmYWNbMF0gPSAxOwogIGludlswXSA9IDE7CiAgUkUgKG4sIE4gLSAxKSB7CiAgICBpbnZbbl0gPSBJbnYobik7CiAgICBEW25dWzBdID0gMTsKICAgIGZhY1tuXSA9IG4gKiBmYWNbbiAtIDFdICUgUDsKICB9CiAgUkUgKG0sIE0gLSAxKSB7CiAgICBpbnQgc3VtID0gKG0gPT0gMSk7CiAgICBSRSAobiwgTiAtIDEpIHsKICAgICAgRFtuXVttXSA9IHN1bSAqIGludltuXSAlIFA7CiAgICAgIHN1bSA9IChzdW0gKyBEW25dW20gLSAxXSArIERbbl1bbV0pICUgUDsKICAgIH0KICB9CiAgCiAgc3BsaXRbMF1bMF0gPSAxOwogIFJFIChnb3QsIEsgLSAxKSB7CiAgICBSRSAobm9uemVybywgSyAtIDEpIHsKICAgICAgc3BsaXRbZ290XVtub256ZXJvXSA9IChzcGxpdFtnb3QgLSAxXVtub256ZXJvXSArIHNwbGl0W2dvdCAtIDFdW25vbnplcm8gLSAxXSkgKiBub256ZXJvICUgUDsKICAgIH0KICB9Cn0KICAKY2xhc3MgQ3ljbGVzTnVtYmVyIHsKICAKcHVibGljOgojdW5kZWYgaW50CiAgdmVjdG9yIDxpbnQ+IGdldEV4cGVjdGF0aW9uKHZlY3RvciA8aW50PiBuLCB2ZWN0b3IgPGludD4gbSkgewogICAgdmVjdG9yPGludD4gcmVzOwojZGVmaW5lIGludCBsb25nIGxvbmcKICAgIEluaXQoKTsKICAgIAogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBTWihuKTsgaSsrKSB7CiAgICAgIGludCBzdW0gPSAwOwogICAgICBkZWJ1ZyhtW2ldKTsKICAgICAgRk9SIChqLCAwLCBtW2ldKSB7CiAgICAgICAgc3VtICs9IHNwbGl0W21baV1dW2pdICogRFtuW2ldXVtqXSAlIFAgKiBmYWNbbltpXV0gJSBQOwogICAgICB9CiAgICAgIHJlcy5QQihzdW0gJSBQKTsKICAgIH0KICAgIHJldHVybiByZXM7CgogIH0KCn07
compilation info
prog.cpp: In function 'int Inv(int)':
prog.cpp:20:25: error: 'max' was not declared in this scope
return spow(max(a, 1ll), P - 2);
^
prog.cpp: In function 'void Init()':
prog.cpp:27:7: error: 'n' was not declared in this scope
RE (n, N - 1) {
^
prog.cpp:27:15: error: 'RE' was not declared in this scope
RE (n, N - 1) {
^
prog.cpp:32:7: error: 'm' was not declared in this scope
RE (m, M - 1) {
^
prog.cpp:41:7: error: 'got' was not declared in this scope
RE (got, K - 1) {
^
prog.cpp: At global scope:
prog.cpp:52:3: error: 'vector' does not name a type
vector <int> getExpectation(vector <int> n, vector <int> m) {
^
stdout