比赛 |
2024暑期C班集训3 |
评测结果 |
AAEEEEWWWWWWWWWWWWWW |
题目名称 |
挑战 NPH |
最终得分 |
10 |
用户昵称 |
liuyiche |
运行时间 |
0.759 s |
代码语言 |
C++ |
内存使用 |
2.72 MiB |
提交时间 |
2024-07-03 11:58:33 |
显示代码纯文本
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int T, n;
ll k;
ll w[1005];
ll c[1005][1005];
inline void C()
{
for(int i = 0; i <= 1000; ++i)
c[i][i] = 1;
for(int i = 0; i <= 1000; ++i)
c[0][i] = 1;
for(int i = 1; i <= 1000; ++i)
for(int j = i+1; j <= 1000; ++j)
c[i][j] = c[i][j-1]+c[i-1][j-1];
}
int main()
{
freopen("NPH.in", "r", stdin);
freopen("NPH.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> T;
C();
while(T--)
{
cin >> n >> k;
for(int i = 1; i <= n; ++i)
cin >> w[i];
if(n == 1)
{
cout << w[1]*k << '\n';
continue;
}
bool p = true;
for(int i = 1; i <= n; ++i)
if(w[i] != 1)
{
p = false;
break;
}
if(p == true)
{
ll cnt = n;
ll num = 0;
while(k > 0)
{
k -= cnt;
num++;
cnt += (num+1)*c[num+1][n];
}
cout << num << '\n';
}
else cout << k << '\n';
}
return 0;
}