Greedy Algorithm!
#include <iostream>
using namespace std;
int n;
static constexpr int coins[] = {1, 4, 16, 64};
int main(void) {
scanf("%d", &n);
int change = 1024 - n, ans = 0;
for (int i = 3; i >= 0; --i) {
while (change >= coins[i]) {
change -= coins[i];
++ans;
}
}
printf("%d\n", ans);
}