P9034 「KDOI-04」Again Counting Set
条件四要求
当
当
设
感性理解
-
-
-
-
-
- 类似可证对于更大的
\operatorname{mex}(S) ,同样无解。
注意集合内可以有任意正整数个
时间复杂度
#include <bits/stdc++.h>
using namespace std;
long long n, k;
long long solve() {
cin >> n >> k;
if(k == 1) return 0;
long long ans = 0;
if(k >= 4) {
ans += 1 + max(0ll, n - 2);
if(n >= 2) ans += 1 + max(0ll, n - 3);
}
if(k >= 5) {
if(n >= 2) ans++;
if(n >= 3) ans++;
}
if(k == 2) ans++;
return ans;
}
int main() {
#ifdef ALEX_WEI
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
#endif
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T;
cin >> T;
while(T--) cout << solve() << "\n";
return 0;
}