QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#519869 | #1436. Split in Sets | hanmm81 | WA | 1ms | 3712kb | C++14 | 760b | 2024-08-15 08:35:38 | 2024-08-15 08:35:38 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define mod 1000000007
using namespace std;
int n,k,a[100005],jc[100005],ans1,ans2=1;
void dfs(int x,int y,int k){
if (x < 0 || k == 0 || y > n) return;
int cnt = 0,sum = 0;
for (;y <= n;y++){
if (a[y] >= (1ll<<x) && cnt != k-1) cnt++,sum += a[y];
else break;
}
ans1 += sum;
if (cnt != k-1) dfs(x-1,y,k-cnt);
else{
int andd = -1;
for (;y <= n;y++) andd = (andd == -1 ? a[y] : andd&a[y]);
if (andd != -1) ans1 += andd;
}
}
signed main(){
cin >> n >> k,jc[0] = 1;
for (int i = 1;i <= max(n,k);i++) jc[i] = jc[i-1]*i%mod;
for (int i = 1;i <= n;i++) cin >> a[i];
sort(a+1,a+n+1,[](int a,int b){return(a>b);});
dfs(31,1,k);
cout << ans1 << " " << jc[k];
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
input:
3 2 4 7 5
output:
11 2
result:
ok 2 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
4 1 44 47 74 77
output:
8 1
result:
ok 2 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3632kb
input:
4 4 44 47 74 77
output:
242 24
result:
ok 2 tokens
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3712kb
input:
1000 975 633065 7087 25267 3940676 618039 1695 2043 728466935 3498 13604984 4 99 119488 151315 12 32 52705062 26815 1902279 33952 480604 390647001 60 1 12566875 7591859 6 119892 7829822 2129 4 11644639 17 33200 5330 338 2 9 6862 3781 148087 57 198 13224999 10493180 1 5755424 216 1757297 210 1002623 ...
output:
35467198613 394187502
result:
wrong answer 2nd words differ - expected: '671056390', found: '394187502'