QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#417835 | #8723. 乘二 | ucup-team1338# | WA | 38ms | 15100kb | C++20 | 1.3kb | 2024-05-22 23:10:40 | 2024-05-22 23:10:40 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n,k;
const int maxn=2e5+5;
const long long mod=1e9+7;
long long a[maxn];
vector<int> num[35];
long long qpow(long long a,long long b)
{
long long res=1;
while(b)
{
if(b&1) res=res*a%mod;
a=a*a%mod;b=b/2;
}
return res;
}
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
num[__lg(a[i])].push_back(a[i]);
}
for(int i=0;i<30;i++)
{
if(num[i].size()<=k)
{
k-=num[i].size();
for(int j=0;j<num[i].size();j++)
{
num[i+1].push_back(num[i][j]*2);
num[i][j]=0;
}
}
else
{
if(k==0) break;
sort(num[i].begin(),num[i].end());
for(int j=0;j<k;j++) num[i+1].push_back(num[i][j]*2),num[i][j]=0;
}
}
if(k==0)
{
long long ans=0;
for(int i=0;i<30;i++)
{
for(int j=0;j<num[i].size();j++)
{
ans+=num[i][j];
}
}
printf("%lld\n",ans%mod);
}
else
{
sort(num[30].begin(),num[30].end());
int size=num[30].size();
int w=k/size;
int res=k%size;
long long p1=qpow(2,w),p2=qpow(2,w+1);
long long ans=0;
for(int j=0;j<num[30].size();j++)
{
if(j<res) ans=(ans+num[30][j]*p1%mod)%mod;
else ans=(ans+num[30][j]*p2%mod)%mod;
}
printf("%lld\n",ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3752kb
input:
3 3 7 2 1
output:
15
result:
ok 1 number(s): "15"
Test #2:
score: -100
Wrong Answer
time: 38ms
memory: 15100kb
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:
272618122
result:
wrong answer 1st numbers differ - expected: '707034173', found: '272618122'