Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main()
- {
- ifstream cin("bac.txt");
- int n,k,put=2;
- int cont_par,aux,ok;
- cin>>n;
- while(cin>>k){
- cont_par=1;
- aux=k;
- if(k%2==0){
- while(k%2==0 || k==1){
- ok=0;
- if(k/2==1){
- for(int i=cont_par;i>1;i--){
- k*=2;
- }
- cout<<k<<" ";
- break;
- }else{
- ok=1;
- cont_par++;
- k/=2;
- }
- }
- }
- else{
- while(k%2!=0){
- if(put>=k){
- cout<<put<<" ";
- break;
- }else{
- put*=2;
- }
- }
- }
- cont_par=1;
- while(aux%2==0){
- if(aux%2!=0){
- for(int i=cont_par;i>=1;i--){
- put*=2; }
- if(put>=aux){
- cout<<put<<" ";
- break;
- }
- }else{
- cont_par++;
- aux/=2;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement