QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#465295#8723. 乘二ukukWA 0ms3604kbC++141.7kb2024-07-06 19:56:202024-07-06 19:56:20

Judging History

你现在查看的是最新测评结果

  • [2024-07-06 19:56:20]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3604kb
  • [2024-07-06 19:56:20]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define i64 long long
#define LL long long
#define i128 __int128
#define ull unsigned long long
#define db long double 
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define lowbit(x) ((x)&-(x))
#define debug(x) cout<<(#x)<<" = "<<(x)<<'\n'

const double eps=1e-8;
const int mod=1e9+7;
//const int mod=998244353;
const int inf=1e9+7;
const i64 INF=1e9+7;
const int N=2e5+5;
const int M=1e6+5;

//const int g=3;
//const int gi=332748118;

LL qmi(LL a,int b){
	a=(a%mod+mod)%mod;
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;
	return ret;
}
int Sqrt(int x){
	assert(x>=0);
	int t=sqrt(x);
	while((t+1)*(t+1)<=x)t++;
	while(t*t>x)t--;
	return t;
}
int lcm(int x,int y){
	if(!x||!y)return x+y;
	return x/__gcd(x,y)*y;
}

int n;
int k;

int len(int x){
	for(int i=0;i;i++){
		if(!(x>>i))return i;
	}
}
inline void solve(){
	cin>>n>>k;
	priority_queue<int,vector<int>,greater<int>>q;
	int h=0;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		q.push(x);
		h=max(h,len(x));
	}
	vector<int>a;
	while(k&&q.size()){
		int x=q.top();q.pop();
		if(len(x)==h)a.pb(x);
		else k--,x<<=1,q.push(x);
	}
	while(q.size()){
		a.pb(q.top());
		q.pop();
	}
	sort(all(a));
	int ans=0;
	for(int i=0;i<a.size();i++){
		int c=k/a.size();
		if(i+1<=k%a.size())c++;
//		debug(a[i]);
//		debug(c);
		ans+=a[i]*qmi(2,c)%mod;
		ans%=mod;
	}
	cout<<ans;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int _=1;
//	cin>>_;
	while(_--)solve();
	return 0;
}
/*

*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3604kb

input:

3 3
7 2 1

output:

0

result:

wrong answer 1st numbers differ - expected: '15', found: '0'