QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#465332#8723. 乘二ukukRE 0ms0kbC++141.8kb2024-07-06 20:06:472024-07-06 20:06:47

Judging History

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

  • [2024-07-06 20:06:47]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-07-06 20:06:47]
  • 提交

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;
	assert(n==3);
	cout<<k<<'\n';
	priority_queue<int,vector<int>,greater<int>>q;
	int h=0;
	for(int i=0;i<n;i++){
//		cout<<"OK\n";
		int x;cin>>x;
		q.push(x);
		h=max(h,len(x));
	}
	debug(h);
	debug(q.size());
	vector<int>a;
	while(k&&q.size()){
		int x=q.top();q.pop();
		debug(x);
		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;
	}
	debug(ans);
	debug(k);
	for(int x:a)debug(x);
	cout<<ans;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int _=1;
//	cin>>_;
	while(_--)solve();
	return 0;
}
/*

*/

详细

Test #1:

score: 0
Runtime Error

input:

3 3
7 2 1

output:


result: