Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve() {
- ll N, P, K; cin >> N >> P >> K;
- cout << 1 << " ";
- mi ans = 1;
- int numOrd = 0;
- ll nxt = -1;
- ll ord = -1;
- ll cur = 1;
- FOR(i, 1, K+1) {
- if (i > N) {
- cout << 0 << " ";
- continue;
- }
- if (getExp(P, N-i+1).v == 1) {
- numOrd++;
- if (nxt == -1) {
- nxt = N-i+1;
- }
- } else {
- ans *= 1 - getExp(P, N-i+1);
- }
- if (getExp(P, i).v == 1) {
- numOrd--;
- if (ord == -1) {
- ord = i;
- nxt /= i;
- }
- ans *= nxt;
- ans *= inv(mi(cur));
- nxt--; cur++;
- } else {
- ans *= inv(1 - getExp(P, i));
- }
- ans *= getExp(P, N) - getExp(P, i-1);
- cout << (numOrd==0?ans:0) << " ";
- }
- cout << nl;
- }
Advertisement
Add Comment
Please, Sign In to add comment