提交时间:2022-07-29 17:21:15

运行 ID: 54818

#include<bits/stdc++.h> using namespace std; int x[100]={1,2,4,8,16,32,64,128},a,b,c; int main(){ while(cin>>a&&a!=0){ for(int i=0;i<=6;i++)if(a>=x[i]&&a<x[i+1])c=i; for(int i=c;i>=0;i--)if(a>=x[i])a-=x[i],b=i; cout<<x[b]<<endl; } return 0; }