#include<bits/stdc++.h>usingnamespace std;#defineintlonglongconstint N =2e5+10;constint mod =1e9+7;int dp[N];int a[N];voidsolve(){int n, k;cin >> n >> k;for(int i =1; i <= n; i ++){cin >> a[i];}sort(a +1, a +1+ n);int ans =1;for(int i =1; i <= n && k; i ++){if(a[i]<31&&(1<<(a[i]-1))<= k){ans = ans * dp[a[i]]% mod;k -=(1<<(a[i]-1));}else{int x =1;// a[i] 拆成 1 ~ i - 1ans = ans * a[i]% mod;k --;while(k){if(1<<(x -1)<= k){k -=1<<(x -1);ans = ans * dp[x]% mod;x ++;}else{ans = ans * x % mod;x =1;k --;}}break;}}cout << ans << endl;}signedmain(){// 1 : f(1) = 1 * 1// 2 : f(2) = 2 * f(1)// 3 : f(3) = 3 * f(2) * f(1)// 4 : f(4) = 4 * f(3) * f(2) * f(1)dp[0]=1;int res =1;for(int i =1; i <=30; i ++){dp[i]= i * res % mod;res = res * dp[i]% mod;}int T;cin >> T;while(T --){solve();}return0;}
【Kafka面試精講 Day 1】Kafka核心概念與分布式架構
在“Kafka面試精講”系列的第1天,我們將深入解析Apache Kafka最根本的基石——核心概念與分布式架構。作為大數據和后端開發領域面試中的“必考題”,諸如“Kafka是如何實現高吞吐量的?”、…