Editorial for Bedao Regular Contest 06 - HALLOWEEN
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Code mẫu
#include <bits/stdc++.h> using namespace std; #define fo(i, a, b) for(int i = a; i <= b; i++) #define _fo(i, a, b) for(int i = a; i >= b; i--) #define foa(i, a) for (auto &i : a) #define sz(a) ((int) a. size()) #define all(a) begin(a), end(a) #define fi first #define se second #define pb(x) push_back(x) #define mk(x, y) make_pair(x, y) typedef unsigned long long ull; typedef long long ll; typedef pair<ll, ll> pll; typedef vector<ll> vl; typedef pair<int, int> pii; typedef vector<int> vi; const int MAX = 1e5+5; const int LOG = 20; const ll MOD = 1e9+7; const ll INF = 1e9+1; const int SQRT = 44721; ll add(ll a, ll b) { return (a+b) % MOD; } ll sub(ll a, ll b) { return (a-b+MOD) % MOD; } ll mul(ll a, ll b) { return (a % MOD)*(b % MOD) % MOD; } ll inv(ll val) { ll curr = 1, temp = MOD-2; while(temp > 0) { if(temp & 1) curr = mul(curr, val); val = mul(val, val); temp >>= 1; } return curr; } ll comb(ll a, ll b) { if(b > a) return 0; b = min(b, a-b); ll temp = 1, fac = 1; fo(i, 1, b) temp = mul(temp, a-i+1); fo(i, 1, b) fac = mul(fac, i); return mul(temp, inv(fac)); } ll candy(ll a, ll b) { return comb(a+b-1, b); } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); ll n, k; cin >> n >> k; cout << candy((n/k)*2, n%k); } /* 1 2 2 0000 */
Comments