Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int n,k,x;
- long long int* a;
- long long int orall()
- {
- long long int resuilt=0;
- for(int i=0;i<n;i++)
- {
- resuilt=resuilt|a[i];
- }
- return resuilt;
- }
- int timmax()
- {
- int max=0;
- for(int i=1;i<n;i++)
- if(a[max]<a[i])
- max=i;
- return max;
- }
- void inkq()
- {
- if(k>=2)
- {
- while(k)
- {
- a[timmax()]*=x;
- k--;
- }
- cout<<orall();
- }
- else
- {
- long long int v=orall();
- int max=orall();
- for(int i=0;i<n;i++)
- {
- if(a[i]!=0)
- {
- a[i]=a[i]*x;
- v=orall();
- if(v>max)
- max=v;
- a[i]=a[i]/x;
- }
- }
- cout<<max;
- }
- }
- int main()
- {
- cin>>n>>k>>x;
- a=new long long int[n];
- for(int i=0;i<n;i++)
- {
- cin>>a[i];
- }
- inkq();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement