Advertisement
Guest User

Untitled

a guest
Jan 19th, 2017
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int n,k,x;
  4. long long int* a;
  5. long long int orall()
  6. {
  7. long long int resuilt=0;
  8. for(int i=0;i<n;i++)
  9. {
  10. resuilt=resuilt|a[i];
  11. }
  12. return resuilt;
  13. }
  14. int timmax()
  15. {
  16. int max=0;
  17. for(int i=1;i<n;i++)
  18. if(a[max]<a[i])
  19. max=i;
  20. return max;
  21. }
  22. void inkq()
  23. {
  24. if(k>=2)
  25. {
  26. while(k)
  27. {
  28. a[timmax()]*=x;
  29. k--;
  30. }
  31. cout<<orall();
  32. }
  33. else
  34. {
  35. long long int v=orall();
  36. int max=orall();
  37. for(int i=0;i<n;i++)
  38. {
  39. if(a[i]!=0)
  40. {
  41. a[i]=a[i]*x;
  42. v=orall();
  43. if(v>max)
  44. max=v;
  45. a[i]=a[i]/x;
  46. }
  47. }
  48. cout<<max;
  49. }
  50. }
  51. int main()
  52. {
  53. cin>>n>>k>>x;
  54. a=new long long int[n];
  55. for(int i=0;i<n;i++)
  56. {
  57. cin>>a[i];
  58. }
  59. inkq();
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement