贪心算法
找零
http://www.nowcoder.com/practice/944e5ca0ea88471fbfa73061ebe95728
#include<bits/stdc++.h> using namespace std; int n; int arr[4]={1,4,16,64}; int need[4]; int solve() { int res=0; int val=1024-n; int loop=3; while( val ) { res+=( val/arr[loop] ); val%=arr[loop]; --loop; } return res; } int main() { while( ~scanf("%d",&n) ) { printf("%d\n",solve() ); } return 0; }