QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417008 | #8723. 乘二 | ucup_team_qiuly# | WA | 52ms | 12512kb | C++14 | 1.2kb | 2024-05-22 12:46:02 | 2024-05-22 12:46:03 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#define mod 998244353
using namespace std;
int n,k,a[200005];
vector<int> c[35];
int popc(int x){
int ans=0;
while(x)ans++,x>>=1;
return ans;
}
int sum(){
int ans=0;
for (int i=0;i<=30;i++)
for (int j=0;j<(int)c[i].size();j++)
ans=(ans+c[i][j])%mod;
return ans;
}
int Qpow(int a,int p){
if (p==0)return 1;
int t=Qpow(a,p/2);
t=1ll*t*t%mod;
if (p&1)t=1ll*t*a%mod;
return t;
}
int main(){
cin>>n>>k;
for (int i=1;i<=n;i++)scanf("%d",&a[i]),c[popc(a[i])].push_back(a[i]);
for (int i=1;i<30;i++){
sort(c[i].begin(),c[i].end());
if (k==0)continue;
for (int j=0;j<(int)c[i].size();j++){
c[i+1].push_back(c[i][j]*2);
c[i][j]=0;
k--;
if (k==0)break;
}
}
int ans=0;
if (k==0)ans=sum();
else{
sort(c[30].begin(),c[30].end());
int l=c[30].size();
for (int i=0;i<l;i++){
int t=k/l;
if (i<k%l)t++;
ans=(ans+1ll*c[30][i]*Qpow(2,t)%mod)%mod;
}
}
cout<<ans<<endl;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3728kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 52ms
memory: 12512kb
input:
200000 1605067 366760624 67854 93901 693975 27016 1046 10808 6533158 54778 500941023 77236442 32173 10431454 2 9726 1553148 89282 411182309 494073 131299543 249904771 7906930 353 9909 3632698 29156 1917186 303 737 1189004 22 1983 263 711 4106258 2070 36704 12524642 5192 123 2061 22887 66 380 1 10153...
output:
970069728
result:
wrong answer 1st numbers differ - expected: '707034173', found: '970069728'