Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ll compAns(int N, vi factors) {
- vi counts;
- int left = N;
- int curDig = 0;
- bool used = false;
- ll ans = 1;
- int added = 0;
- F0R(i, sz(factors)) {
- int nxt = left / factors[i];
- curDig++;
- counts.pb(left - nxt);
- left = nxt;
- }
- F0R(dig, sz(counts)) {
- int cur = counts[dig];
- ans = mul(ans, cur);
- cur--;
- F0R(i, cur) {
- ans = mul(ans, added + 1);
- added++;
- }
- added++;
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment