C++ 代码
#include <iostream>
#include <vector>
using namespace std;
int main()
{
int n;
cin >> n;
int res = 0;
if(n >= 1024) res = 0;
vector<int> a{64, 16, 4, 1};
n = 1024 - n;
for(int i = 0; i < 4; i++)
{
int temp = n / a[i];
if(temp >= 0)
{
res += temp;
n = n - temp * a[i];
}
else{
break;
}
}
cout<<res<<endl;
return 0;
}