激励
每当在书中读及那些卑微的努力,都觉得感动且受震撼。也许每个人在发出属于自己的光芒之前,都经历了无数的煎熬,漫长的黑夜,无尽的孤独,甚至不断的嘲讽和否定,但好在那些踮脚的少年,最后都得到了自己想要的一切。
link
https://me.csdn.net/sz_165394732
https://www.luogu.org/discuss/show/82076
compare
int jc[mod], ijc[mod];
inline int qpow(int x, int y) {
int r=1;
for (; y; y>>=1, x=x*x%mod) if (y&1) r=r*x%mod;
return r;
}
inline void init() {
jc[0]=1; for (int i=1; i<mod; ++i) jc[i]=jc[i-1]*i%mod;
ijc[mod-1]=qpow(jc[mod-1], mod-2);
for (int i=mod-2; i>=0; --i) ijc[i]=ijc[i+1]*(i+1)%mod;
}
inline int C(int x, int y) {return jc[x]*(ijc[x-y]*ijc[y]%mod)%mod; }
inline int lucas(int x, int y) {
if (y>x) return 0;
int r=1;
for (; y; x/=mod, y/=mod) r=r*C(x%mod, y%mod);
return r;
}
int T, n, m;
int main() {
init();
scanf("%d", &T);
while (T--) {
scanf("%d%d", &n, &m);
printf("%d\n", lucas(n, m));
}
return 0;
}
int jc[mod], inv[mod], t, n, m;
inline int lucas(int a, int b) {
if (a > b) return 0;
if (b <= mod) return jc[b] * inv[a] % mod * inv[b - a] % mod;
return lucas(a / mod, b / mod) * lucas(a % mod, b % mod) % mod;
}
int main(void) {
jc[0] = jc[1] = inv[0] = inv[1] = 1;
for (int i = 2; i < mod; ++i) jc[i] = jc[i - 1] * i % mod, inv[i] = (mod - mod / i) * inv[mod % i] % mod;
for (int i = 2; i < mod; ++i) inv[i] = inv[i - 1] * inv[i] % mod;
for (scanf("%d", &t); t; --t) scanf("%d%d", &n, &m), printf("%d\n", lucas(m, n));
return 0;
}
ぼくのフレンド (Boku no Friend)
aienkien ichigoichie
sode suriau mo tashou no en
kono yo no kiseki gyutto tsumete
kimi to deaetanda
aoi haru itsuka maku o toji
sakura to tomo ni maichittemo
kanarazu bokura mata dokoka de
deai o hatasu darou
kakegae nai
boku to nita kimi e
hitori de koronde kizu darake ni natta toki wa
itsudemo dokomademo hashiru yo
tama ni wa kenka shite okorou
nakigao mitara nagusameyou
tobikiri no nagai o sekkyou wa mijikame ni shite
kirei na mono o sagashi ni yukou
oishii mono mo takusan tabeyou
tsumari wa korekara mo douka yoroshiku ne
toki ga tatsu no wa hayai mono de
wakare no kisetsu ga kao o dasu
tsumiagetekita mono ga yake ni
namida o sasounda
aoi haru ga ima maku o toji
sakura ga chiru oto wa shizuka de
setsunai omoi ga oshiyoseta
sayonara no yuuyake
kakegae nai
boku to nita kimi wa
hitori demo daijoubu dakara tada mae o mite
hirogaru michi o hashirunda
tama ni wa futari katariaou
iya na koto zenbu hakidasou
tobikiri no nagai adobaisu wa chanto kiitete
ureshii koto wa houkoku shiyou
atarashii deai daiji ni shiyou
tsumari wa itsudemo itsumademo?
aa bokura wa tatta ima
gooru wa betsubetsu sutaato rain
omoide shimaikonde
fumidashita saki wa mirai e
kakegae nai
boku to nita kimi wa
hitori demo daijoubu dakara tada mae o mite
hirogaru michi o hashirunda
tama ni wa hodohodo ni yasumou
yasumetara yururi to susumou
tobikiri nagai kinkyou houkoku omachi shitemasu
doredake teki o tsukurou tomo
boku ga kimi no mikata de iru kara
tsumari wa korekara mo douka yoroshiku ne